Try something else
This commit is contained in:
parent
e3cb68551b
commit
9c11d8d494
|
@ -61,11 +61,11 @@ def main():
|
||||||
# Build an INSERT statement based on the fields we have from the frame
|
# Build an INSERT statement based on the fields we have from the frame
|
||||||
attrib_names = ', '.join('"%s"' % w for w in a.keys())
|
attrib_names = ', '.join('"%s"' % w for w in a.keys())
|
||||||
attrib_values = ", ".join("?" * len(a.keys()))
|
attrib_values = ", ".join("?" * len(a.keys()))
|
||||||
sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Insert data
|
# Insert data
|
||||||
|
sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
|
||||||
conn.execute(sql, list(a.values()))
|
conn.execute(sql, list(a.values()))
|
||||||
|
|
||||||
# TODO update stations table here
|
# TODO update stations table here
|
||||||
|
@ -75,7 +75,7 @@ def main():
|
||||||
# Build query
|
# Build query
|
||||||
# "from" is wrappedin [] because it is a reserved word and using '' doesn't work.
|
# "from" is wrappedin [] because it is a reserved word and using '' doesn't work.
|
||||||
# https://www.sqlite.org/lang_keywords.html
|
# https://www.sqlite.org/lang_keywords.html
|
||||||
try:
|
#try:
|
||||||
station_update = "'"+a['from'] +"', '"+ str(a['created_unix']) +"', '1'"
|
station_update = "'"+a['from'] +"', '"+ str(a['created_unix']) +"', '1'"
|
||||||
query3 = "INSERT INTO stations ([from], last_heard_unix, count) \
|
query3 = "INSERT INTO stations ([from], last_heard_unix, count) \
|
||||||
VALUES("+station_update+") \
|
VALUES("+station_update+") \
|
||||||
|
@ -84,9 +84,10 @@ def main():
|
||||||
print(query3)
|
print(query3)
|
||||||
# Insert/update data
|
# Insert/update data
|
||||||
conn.execute(query3)
|
conn.execute(query3)
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
except:
|
#except:
|
||||||
print("Stations table couldn't be updated.")
|
# print("Stations table couldn't be updated.")
|
||||||
|
|
||||||
# TODO remove packets that are older ('created') than a limit set in config.ini
|
# TODO remove packets that are older ('created') than a limit set in config.ini
|
||||||
# "5 minutes" also works
|
# "5 minutes" also works
|
||||||
|
|
Loading…
Reference in New Issue
Block a user