Added check to helpers.get_config to dynamically add missing column

readme-wiki
xorrior 2017-12-18 12:00:59 -05:00
parent 62ddcbb2a6
commit 659b15f86c
1 changed files with 7 additions and 0 deletions

View File

@ -547,6 +547,13 @@ def get_config(fields):
conn.isolation_level = None
cur = conn.cursor()
# Check if there is a new field not in the database
columns = [i[1] for i in cur.execute('PRAGMA table_info(config)')]
for field in fields.split(','):
if field.strip() not in columns:
cur.execute("ALTER TABLE config ADD COLUMN %s BLOB" % (field))
cur.execute("SELECT %s FROM config" % (fields))
results = cur.fetchone()
cur.close()