Skip to content

Commit

Permalink
Ignore MySQL warnings.
Browse files Browse the repository at this point in the history
MySQL returned a warning when checking if a non-existing table exists (in the DROP TABLE IF EXISTS query). I tried to filter out this warning using the filterwarnings() function, but it did not work, so no we just ignore them all.
  • Loading branch information
akoch8 committed Jul 19, 2018
1 parent fd7cbd3 commit 89d175f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/upload_tcga_data.py
Expand Up @@ -32,6 +32,7 @@
import pymysql
import sys
import upload_annotation_data as uad
import warnings

from contextlib import closing

Expand Down Expand Up @@ -115,7 +116,13 @@ def create_table(login_info, table, file, file_path):
# statements and execute them separately.
sql = sql.rstrip(';')
for s in sql.split(';'):
cur.execute(s)
with warnings.catch_warnings():
# Ignore MySQL warning that table does not exist when checking
# if it exists. Couldn't get the filterwarnings function to
# select this specific warning, so now we're just ignoring them
# all.
warnings.simplefilter('ignore')
cur.execute(s)
conn.commit()
except Exception as e:
print 'ERROR: SQL query failed'
Expand Down

0 comments on commit 89d175f

Please sign in to comment.