Add background KISS connection, log frames to database #20

Merged
W1CDN merged 10 commits from add-kiss into main 2023-04-16 16:45:54 -05:00
2 changed files with 21 additions and 9 deletions
Showing only changes of commit ef5765e87f - Show all commits

View File

@ -31,6 +31,11 @@ db_fields = ("id",
"object_name",
"path",
"phg",
"phg_dir",
"phg_gain",
"phg_height",
"phg_power",
"phg_range",
"posambiguity",
"raw",
"raw_timestamp",
@ -95,15 +100,17 @@ def main():
attrib_values = ", ".join("?" * len(a.keys()))
#sql = f"INSERT INTO frames ({attrib_names}) VALUES ({attrib_values})"
sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
print(sql)
# Insert data
conn.execute(sql, list(a.values()))
conn.commit()
try:
# Insert data
conn.execute(sql, list(a.values()))
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']+"')")
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']+"')")
conn.commit()
except:
print("Error with SQLite!")
conn.close()

View File

@ -21,7 +21,12 @@ CREATE TABLE frames (
object_format TEXT,
object_name TEXT,
path TEXT,
phg TEXT,
phg REAL,
phg_dir TEXT,
phg_gain REAL,
phg_height REAL,
phg_power REAL,
phg_range REAL,
posambiguity INT,
raw TEXT,
raw_timestamp TEXT,