Skip to content

Commit 82f2da2

Browse files
committed
Ensure transaction flag is reset and avoid __ function name
1 parent 0b1e3bc commit 82f2da2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

datajoint/connection.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def __init__(self, host, user, password, port=None, init_fun=None, use_tls=None)
124124
self.connection_id = self.query('SELECT connection_id()').fetchone()[0]
125125
else:
126126
raise errors.ConnectionError('Connection failed.')
127-
self._in_transaction = False
128127
self.schemas = dict()
129128
self.dependencies = Dependencies(self)
130129

@@ -160,6 +159,8 @@ def connect(self):
160159
if not(k == 'ssl_input' or
161160
k == 'ssl' and self.conn_info['ssl_input'] is None)})
162161
self._conn.autocommit(True)
162+
self._in_transaction = False
163+
163164

164165
def close(self):
165166
self._conn.close()
@@ -185,7 +186,7 @@ def is_connected(self):
185186
return True
186187

187188
@staticmethod
188-
def __execute_query(cursor, query, args, cursor_class, suppress_warnings):
189+
def _execute_query(cursor, query, args, cursor_class, suppress_warnings):
189190
try:
190191
with warnings.catch_warnings():
191192
if suppress_warnings:
@@ -211,7 +212,7 @@ def query(self, query, args=(), *, as_dict=False, suppress_warnings=True, reconn
211212
cursor_class = client.cursors.DictCursor if as_dict else client.cursors.Cursor
212213
cursor = self._conn.cursor(cursor=cursor_class)
213214
try:
214-
self.__execute_query(cursor, query, args, cursor_class, suppress_warnings)
215+
self._execute_query(cursor, query, args, cursor_class, suppress_warnings)
215216
except errors.LostConnectionError:
216217
if not reconnect:
217218
raise
@@ -222,7 +223,7 @@ def query(self, query, args=(), *, as_dict=False, suppress_warnings=True, reconn
222223
raise errors.LostConnectionError("Connection was lost during a transaction.") from None
223224
logger.debug("Re-executing")
224225
cursor = self._conn.cursor(cursor=cursor_class)
225-
self.__execute_query(cursor, query, args, cursor_class, suppress_warnings)
226+
self._execute_query(cursor, query, args, cursor_class, suppress_warnings)
226227
return cursor
227228

228229
def get_user(self):

0 commit comments

Comments
 (0)