X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=gps303%2Fevstore.py;h=9bc60d5594a1f7656360fff741cbe1470ed346ab;hb=4c9597cff07443042f51c2330a050b7ee5bc9bcb;hp=1b1ae2dc398f29063ffcddf2716da7b2424de01c;hpb=d75412f9c32046da5659728e82adaa9607dd0b74;p=loctrkd.git diff --git a/gps303/evstore.py b/gps303/evstore.py index 1b1ae2d..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) 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), ) ) - log.debug("inserting %s", parms) 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()