#!/usr/bin/python # # # 3/30/2015 Paul Mattione # # # This script sets the roc id for rocSTPSC2 # import sqlite3 as lite import sys import os import re import datetime if len(sys.argv) != 2: print "You must supply a SQLite DB file to modify!" sys.exit(0); # 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) with con: # Specify that next cursor should be "dictionary" # (i.e. python's hash map) so columns can be indexed # by name con.row_factory = lite.Row # Create Cursor cur = con.cursor() # Check that this TT file has not already been updated cur.execute("SELECT rocid FROM Crate WHERE crateid='11'") row = cur.fetchall()[0] if row['rocid'] == 96: print 'rocid already fixed' sys.exit(-1) # Update other channels for RF (were SPARE) cur.execute("UPDATE Crate SET rocid='96' WHERE crateid='11'") #rocstpsc2 print 'Done'