From 0a46ee4f470596c1757856f4ce4015a1ced22e8c Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Sat, 7 May 2022 12:59:12 +0200 Subject: [PATCH] Update evstore schema to support in and out msgs --- gps303/evstore.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gps303/evstore.py b/gps303/evstore.py index c10ecb1..ec463c7 100644 --- a/gps303/evstore.py +++ b/gps303/evstore.py @@ -1,6 +1,6 @@ """ sqlite event store """ -from sqlite3 import connect +from sqlite3 import connect, OperationalError __all__ = "fetch", "initdb", "stow" @@ -10,6 +10,7 @@ SCHEMA = """create table if not exists events ( tstamp real not null, imei text, peeraddr text not null, + is_incoming int not null default TRUE, proto int not null, packet blob )""" @@ -18,7 +19,11 @@ SCHEMA = """create table if not exists events ( def initdb(dbname): global DB DB = connect(dbname) - DB.execute(SCHEMA) + try: + DB.execute("""alter table events add column + is_incoming int not null default TRUE""") + except OperationalError: + DB.execute(SCHEMA) def stow(**kwargs): -- 2.39.2