X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=gps303%2Fevstore.py;fp=gps303%2Fevstore.py;h=9bc60d5594a1f7656360fff741cbe1470ed346ab;hb=4aaa5cd899d6b2bb9fd5e90dfac3d43461394e9b;hp=360ab359505c7a141cdf6a5857d7dbcc14c86b53;hpb=fd7f5f3424b04b1ffcb66bc06588e4b4dbe84900;p=loctrkd.git diff --git a/gps303/evstore.py b/gps303/evstore.py index 360ab35..9bc60d5 100644 --- a/gps303/evstore.py +++ b/gps303/evstore.py @@ -11,6 +11,7 @@ SCHEMA = """create table if not exists events ( timestamp real not null, imei text, clntaddr text not null, + length int, proto int not null, payload blob )""" @@ -18,23 +19,25 @@ SCHEMA = """create table if not exists events ( def initdb(dbname): global DB - log.info("Using Sqlite3 database \"%s\"", dbname) + log.info('Using Sqlite3 database "%s"', dbname) DB = connect(dbname) DB.execute(SCHEMA) -def stow(clntaddr, timestamp, imei, proto, payload): +def stow(clntaddr, timestamp, imei, length, proto, payload): assert DB is not None parms = dict( zip( - ("clntaddr", "timestamp", "imei", "proto", "payload"), - (str(clntaddr), timestamp, imei, proto, payload), + ("clntaddr", "timestamp", "imei", "length", "proto", "payload"), + (str(clntaddr), timestamp, imei, length, proto, payload), ) ) DB.execute( """insert or ignore into events - (timestamp, imei, clntaddr, proto, payload) - values (:timestamp, :imei, :clntaddr, :proto, :payload)""", + (timestamp, imei, clntaddr, length, proto, payload) + values + (:timestamp, :imei, :clntaddr, :length, :proto, :payload) + """, parms, ) DB.commit()