Try to fix race condition in frames and stations tables.
This commit is contained in:
parent
d2cdaa820a
commit
e3cb68551b
|
@ -62,6 +62,7 @@ def main():
|
||||||
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+")"
|
sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Insert data
|
# Insert data
|
||||||
|
@ -69,7 +70,7 @@ def main():
|
||||||
|
|
||||||
# TODO update stations table here
|
# TODO update stations table here
|
||||||
# Original intent was to include the id from the frames table,
|
# 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.
|
# It's not immediately needed, so I'm skipping it.
|
||||||
# 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.
|
||||||
|
@ -83,11 +84,10 @@ def main():
|
||||||
print(query3)
|
print(query3)
|
||||||
# Insert/update data
|
# Insert/update data
|
||||||
conn.execute(query3)
|
conn.execute(query3)
|
||||||
|
conn.commit()
|
||||||
except:
|
except:
|
||||||
print("Stations table couldn't be updated.")
|
print("Stations table couldn't be updated.")
|
||||||
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
# 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
|
||||||
#conn.execute("DELETE FROM frames WHERE created < DATETIME('now', '"+config['Settings']['keep_time']+"')")
|
#conn.execute("DELETE FROM frames WHERE created < DATETIME('now', '"+config['Settings']['keep_time']+"')")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user