comparison python/storage.py @ 922:acb5379c5fd7

corrected
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 05 Jul 2017 18:07:53 -0400
parents 630934595871
children c030f735c594
comparison
equal deleted inserted replaced
921:630934595871 922:acb5379c5fd7
595 def savePrototypesToSqlite(filename, prototypes): 595 def savePrototypesToSqlite(filename, prototypes):
596 '''save the prototypes (a prototype is defined by a filename, a number and type''' 596 '''save the prototypes (a prototype is defined by a filename, a number and type'''
597 connection = sqlite3.connect(filename) 597 connection = sqlite3.connect(filename)
598 cursor = connection.cursor() 598 cursor = connection.cursor()
599 try: 599 try:
600 cursor.execute('CREATE TABLE IF NOT EXISTS prototypes (dbfilename VARCHAR, id INTEGER, trajectory_type VARCHAR CHECK (trajectory_type IN (\"feature\", \"object\")), nmatchings INTEGER, PRIMARY KEY (id, dbfilename))') 600 cursor.execute('CREATE TABLE IF NOT EXISTS prototypes (filename VARCHAR, id INTEGER, trajectory_type VARCHAR CHECK (trajectory_type IN (\"feature\", \"object\")), nmatchings INTEGER, PRIMARY KEY (filename, id))')
601 for p in prototypes: 601 for p in prototypes:
602 cursor.execute('INSERT INTO prototypes (dbfilename, id, trajectory_type, nmatchings) VALUES (?,?,?,?)', (p.getFilename(), p.getNum(), p.getTrajectoryType(), p.getNMatchings())) 602 cursor.execute('INSERT INTO prototypes (filename, id, trajectory_type, nmatchings) VALUES (?,?,?,?)', (p.getFilename(), p.getNum(), p.getTrajectoryType(), p.getNMatchings()))
603 except sqlite3.OperationalError as error: 603 except sqlite3.OperationalError as error:
604 printDBError(error) 604 printDBError(error)
605 connection.commit() 605 connection.commit()
606 connection.close() 606 connection.close()
607 607