Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 64 additions & 26 deletions VariantValidator/modules/vvDBGet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,75 @@ class Mixin(vvDBInit.Mixin):

@handleCursor
def execute(self, *query_args):
# Connect and create cursor
conn = self.get_conn()
cursor = self.get_cursor(conn)
attempts = 3

cursor.execute(*query_args)
row = cursor.fetchone()
if row is None:
logger.debug("No data returned from query " + str(query_args))
row = ['none', 'No data']
for attempt in range(attempts):
conn = self.get_conn()
cursor = self.get_cursor(conn)

# Close conn
cursor.close()
conn.close()
return row
try:
cursor.execute(*query_args)
row = cursor.fetchone()

if row is None:
logger.debug(f"No data returned from query {query_args}")
row = ['none', 'No data']

return row

except Exception as e:
logger.warning(f"MySQL error (attempt {attempt + 1}/{attempts}): {e}")

if attempt < attempts - 1:
try:
conn.reconnect(attempts=1, delay=0)
except Exception:
pass
else:
raise

finally:
try:
cursor.close()
conn.close()
except Exception:
pass

@handleCursor
def execute_all(self, *query_args):
# Connect and create cursor
conn = self.get_conn()
cursor = self.get_cursor(conn)

cursor.execute(*query_args)
rows = cursor.fetchall()
if not rows:
logger.debug("No data returned from query " + str(query_args))
rows = ['none', 'No data']

# Close conn
cursor.close()
conn.close()
return rows
attempts = 3

for attempt in range(attempts):
conn = self.get_conn()
cursor = self.get_cursor(conn)

try:
cursor.execute(*query_args)
rows = cursor.fetchall()

if not rows:
logger.debug(f"No data returned from query {query_args}")
rows = [['none', 'No data']]

return rows

except Exception as e:
logger.warning(f"MySQL error (attempt {attempt + 1}/{attempts}): {e}")

if attempt < attempts - 1:
try:
conn.reconnect(attempts=1, delay=0)
except Exception:
pass
else:
raise

finally:
try:
cursor.close()
conn.close()
except Exception:
pass

# from dbfetchone
def get_uta(self, gene_symbol):
Expand Down
Empty file.
5 changes: 4 additions & 1 deletion tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ def write_config(self):

def test_file_structure(self):

self.assertCountEqual(self.config.sections(), ['mysql', 'seqrepo', 'postgres', 'logging', 'Entrez'])
try:
self.assertCountEqual(self.config.sections(), ['mysql', 'seqrepo', 'postgres', 'logging', 'Entrez'])
except AssertionError:
self.assertCountEqual(self.config.sections(), ['mysql', 'seqrepo', 'postgres', 'logging', 'Entrez', 'auth'])
self.assertCountEqual(list(self.config['mysql']), ['host', 'port', 'database', 'user', 'password', 'version'])
self.assertCountEqual(list(self.config['seqrepo']), ['version', 'location', 'require_threading'])
self.assertCountEqual(list(self.config['postgres']), ['host', 'port', 'database', 'version', 'user', 'password'])
Expand Down