From: Eugene Crosser Date: Sat, 7 May 2022 10:59:12 +0000 (+0200) Subject: Update evstore schema to support in and out msgs X-Git-Tag: 0.01~1 X-Git-Url: http://www.average.org/gitweb/?p=loctrkd.git;a=commitdiff_plain;h=0a46ee4f470596c1757856f4ce4015a1ced22e8c Update evstore schema to support in and out msgs --- 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):