Skip to content

Commit 3f0a19c

Browse files
committed
Suppress warnings from calls to query execution
1 parent d116d22 commit 3f0a19c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

datajoint/connection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,17 @@ def query(self, query, args=(), as_dict=False):
112112
:param as_dict: If as_dict is set to True, the returned cursor objects returns
113113
query results as dictionary.
114114
"""
115+
115116
cursor = client.cursors.DictCursor if as_dict else client.cursors.Cursor
116117
cur = self._conn.cursor(cursor=cursor)
117118

118-
# Log the query
119119
try:
120+
# Log the query
120121
logger.debug("Executing SQL:" + query[0:300])
121-
cur.execute(query, args)
122+
# suppress all warnings arising from underlying SQL library
123+
with warnings.catch_warnings():
124+
warnings.simplefilter("ignore")
125+
cur.execute(query, args)
122126
except err.OperationalError as e:
123127
if 'MySQL server has gone away' in str(e) and config['database.reconnect']:
124128
warnings.warn('''Mysql server has gone away.

0 commit comments

Comments
 (0)