Mercurial Hosting > traffic-intelligence
diff trafficintelligence/storage.py @ 1033:8ffb3ae9f3d2
work in progress
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 20 Jun 2018 00:07:03 -0400 |
parents | aafbc0bab925 |
children | 933588568bec |
line wrap: on
line diff
--- a/trafficintelligence/storage.py Tue Jun 19 17:07:50 2018 -0400 +++ b/trafficintelligence/storage.py Wed Jun 20 00:07:03 2018 -0400 @@ -563,7 +563,7 @@ ######################### def savePrototypesToSqlite(filename, prototypes): - '''save the prototypes (a prototype is defined by a filename, a number (id) and type''' + '''save the prototypes (a prototype is defined by a filename, a number (id) and type)''' with sqlite3.connect(filename) as connection: cursor = connection.cursor() try: @@ -574,6 +574,21 @@ printDBError(error) connection.commit() +def setPrototypeMatchingsInSqlite(filename, prototypes): + '''updates the prototype matchings''' + with sqlite3.connect(filename) as connection: + cursor = connection.cursor() + try: + for p in prototypes: + if p.getNMatchings() is None: + nMatchings = 'NULL' + else: + nMatchings = p.getNMatchings() + cursor.execute('UPDATE prototypes SET nmatchings = {} WHERE prototype_filename = \"{}\" AND prototype_id = {} AND trajectory_type = \"{}\"'.format(nMatchings, p.getFilename(), p.getNum(), p.getTrajectoryType())) + except sqlite3.OperationalError as error: + printDBError(error) + connection.commit() + def savePrototypeAssignmentsToSqlite(filename, objects, objectType, labels, prototypes): with sqlite3.connect(filename) as connection: cursor = connection.cursor()