Try to fix race condition in frames and stations tables.

This commit is contained in:
Matt Old Account 2023-07-12 09:34:39 -05:00
parent d2cdaa820a
commit e3cb68551b

View File

@ -62,6 +62,7 @@ def main():
attrib_names = ', '.join('"%s"' % w for w in a.keys())
attrib_values = ", ".join("?" * len(a.keys()))
sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
conn.commit()
try:
# Insert data
@ -69,7 +70,7 @@ def main():
# TODO update stations table here
# Original intent was to include the id from the frames table,
# but that would mean making another conn.commit() (I think).
# but that would mean making another query.
# It's not immediately needed, so I'm skipping it.
# Build query
# "from" is wrappedin [] because it is a reserved word and using '' doesn't work.
@ -83,11 +84,10 @@ def main():
print(query3)
# Insert/update data
conn.execute(query3)
conn.commit()
except:
print("Stations table couldn't be updated.")
conn.commit()
# TODO remove packets that are older ('created') than a limit set in config.ini
# "5 minutes" also works
#conn.execute("DELETE FROM frames WHERE created < DATETIME('now', '"+config['Settings']['keep_time']+"')")