#!/usr/bin/env python import sqlite3 as lite import sys # Connect to SQLite DB file db_filename = sys.argv[1] print "" print "opening SQLite DB file: %s" % db_filename print "---------------------------------------------" con = lite.connect(db_filename) con.row_factory = lite.Row cur = con.cursor() # insert new ADC module cur.execute("SELECT max(moduleid) FROM Module;") row = cur.fetchone() new_moduleid = str(row[0] + 1) # use hardwired crate id and slot number adcModuleInsertQuery = "INSERT INTO Module VALUES (" + new_moduleid + ", 61, 16, \"fADC250\", \"ACDI-???\");" print(adcModuleInsertQuery) cur.execute(adcModuleInsertQuery) con.commit() # insert new discriminator module cur.execute("SELECT max(moduleid) FROM Module;") row = cur.fetchone() new_moduleid = str(row[0] + 1) # use hardwired crate id and slot number discModuleInsertQuery = "INSERT INTO Module VALUES (" + new_moduleid + ", 63, 15, \"DISC\", \"ACDI-071\");" print(discModuleInsertQuery) cur.execute(discModuleInsertQuery) con.commit()