Snapshot after adding station table update code, but hasn't been tested on real frames yet.

This commit is contained in:
2023-07-09 09:14:09 -05:00
parent ee75cccc68
commit 8d94794c90
2 changed files with 30 additions and 12 deletions

View File

@@ -66,7 +66,18 @@ def main():
conn.execute(sql, list(a.values()))
# 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).
# 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.
station_update = ", ".join((a['from'], a['created_unix'], "1"))
query3 = "INSERT INTO stations ([from], last_heard_unix, count) \
VALUES("+station_update+", 1) \
ON CONFLICT([from]) \
DO UPDATE SET count = count + 1;"
# Insert/update data
conn.execute(query3)
conn.commit()