Skip to content

Commit

Permalink
fixed bug in magsql.py
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesGodwin committed Nov 14, 2023
1 parent c9fe1d2 commit 9069a80
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/magsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def post_data(alldata):
global args, cursor, db_columns
if type(alldata) == list:
alldata = alldata[0]
inserts = {}
for data in alldata['data']:
inserts = {}
db_table = data['device']
if db_table not in db_columns:
return
Expand All @@ -195,10 +195,11 @@ def post_data(alldata):
inserts['timestamp'] = f"\"{timestamp}\""
elif 'datetime' in db_columns[db_table]:
inserts['datetime'] = f"\"{timestamp}\""
rowdata = data['data']
for field in db_columns[db_table]:
if field in data:
if data[field] != None:
value = data[field]
if field in rowdata:
if rowdata[field] != None:
value = rowdata[field]
if type(value) == bool:
if value:
value = str(1)
Expand Down

0 comments on commit 9069a80

Please sign in to comment.