diff python/storage.py @ 340:1046b7346886

work in progress on storing indicator values
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 19 Jun 2013 23:35:24 -0400
parents 3950bfe22768
children 2f39c4ed0b62
line wrap: on
line diff
--- a/python/storage.py	Wed Jun 19 22:56:21 2013 -0400
+++ b/python/storage.py	Wed Jun 19 23:35:24 2013 -0400
@@ -201,6 +201,32 @@
     utils.dropTables(connection, ['objects', 'objects_features'])
     connection.close()
 
+def deleteIndicators(filename):
+    'Deletes all indicator data in db'
+    pass
+
+def saveInteractions(filename, interactions):
+    'Saves the interactions in the table'
+    import sqlite3
+    connection = sqlite3.connect(filename)
+    cursor = connection.cursor()
+    cursor.execute('CREATE TABLE interactions IF NOT EXISTS (id INTEGER PRIMARY KEY, object_id1 INTEGER, object_id2 INTEGER, FOREIGN KEY(object_id1) REFERENCES objects(id), FOREIGN KEY(object_id2) REFERENCES objects(id))')
+    # get the highest interaction id
+    for i in interactions:
+        cursor.execute('INSERT INTO interactions VALUES({})'.format(i.getNum())) # todo getRoadUserNumbers()
+    # CREATE TABLE IF NOT EXISTS interactions (id INTEGER PRIMARY KEY, object_id1 INTEGER, object_id2 INTEGER, FOREIGN KEY(object_id1) REFERENCES objects(id), FOREIGN KEY(object_id2) REFERENCES objects(id));
+    # CREATE TABLE IF NOT EXISTS indicators (id INTEGER PRIMARY KEY, interaction_id INTEGER, indicator_type INTEGER, FOREIGN KEY(interaction_id) REFERENCES interactions(id))
+    # CREATE TABLE IF NOT EXISTS indicator_values (indicator_id INTEGER, frame_number INTEGER, value REAL, FOREIGN KEY(indicator_id) REFERENCES indicators(id), PRIMARY KEY(indicator_id, frame_number))
+
+    connection.close()
+
+def saveIndicators(filename, indicators):
+    'Saves the indicator values in the table'
+    import sqlite3
+    connection = sqlite3.connect(filename)
+    
+
+    connection.close()
 
 #########################
 # txt files