Changeset 871 for trunk/Monitoring/smon/local_repo.py
- Timestamp:
- 06/11/13 09:33:58 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Monitoring/smon/local_repo.py
r866 r871 14 14 import sys 15 15 import sqlite3 16 17 import types 16 18 17 19 _conn=None … … 39 41 40 42 def create_tables(): 43 41 44 _conn.execute("create table simulation (id INTEGER PRIMARY KEY, name TEXT)") 45 _conn.execute("create unique index idx_simulation on simulation (name)") 46 42 47 _conn.execute("create table message (id INTEGER PRIMARY KEY, simulation_id TEXT)") # TODO: check how to use INT datatype for simulation_id column 48 49 def populate_tables_with_sample(): 50 51 rows = [('SIMU-001',), 52 ('SIMU-002',), 53 ('SIMU-003',),] 54 _conn.executemany('INSERT INTO simulation (name) VALUES (?)', rows) 55 56 def retrieve_simulations(): 57 li=[] 58 c=_conn.cursor() 59 60 c.execute("select name,id from simulation") 61 62 rs=c.fetchone() 63 while rs is not None: 64 li.append(types.Simulation(name=rs[0],id=rs[1])) 65 rs=c.fetchone() 66 67 return li 43 68 44 69 def retrieve_simulation(name): … … 52 77 raise Exception() 53 78 54 return smon.types.Simulation(id=rs[1])79 return types.Simulation(id=rs[1]) 55 80 56 81 def delete_simulation(simulation): … … 72 97 rs=c.fetchone() 73 98 while rs is not None: 74 li.append( smon.types.Message(id=rs[0]))99 li.append(types.Message(id=rs[0])) 75 100 rs=c.fetchone() 76 101 … … 93 118 raise Exception() 94 119 95 return smon.types.Message(id=rs[0])120 return types.Message(id=rs[0])
Note: See TracChangeset
for help on using the changeset viewer.