All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
copyPostGresToSQLite Namespace Reference

Functions

def copyTable
 

Variables

list readoutBoardsColumns
 
list daqChannelsColumns
 
list flangesColumns
 
list pmtPlacementColumns
 
list crtFEBChannelsColumns
 
list topcrtFEBColumns
 
string queryurl = "https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query"
 
tuple dataQuery = DataQuery(queryurl)
 
string dbName = "icarus_hardware_prd"
 
string readoutBoardsTable = "readout_boards"
 
string daqChannelsTable = "daq_channels"
 
string flangesTable = "flanges"
 
string pmtPlacementTable = "pmt_placements"
 
string crtfebchannelsTable = "feb_channels"
 
string topcrtfebTable = "crtfeb"
 
tuple sqliteDB = sqlite3.connect("ChannelMapICARUS.db")
 
tuple dbCurs = sqliteDB.cursor()
 

Function Documentation

def copyPostGresToSQLite.copyTable (   postGres,
  dbCurs,
  dbName,
  table,
  columns 
)

Definition at line 132 of file copyPostGresToSQLite.py.

133 def copyTable(postGres, dbCurs, dbName, table, columns):
134  createString = "CREATE TABLE " + table + " ("
135 
136  for columnIdx in range(len(columns)):
137  if columnIdx > 0:
138  createString += ", "
139  createString += columns[columnIdx]
140 
141  createString += ")"
142 
143  print(createString)
144 
145  dbCurs.execute(createString)
146 
147  query = postGres.query(database=dbName, table=table, columns="*")
148 
149  for rowIdx in range(len(query)):
150  rowList = query[rowIdx].split(',')
151  if len(rowList) != len(columns):
152  print("Length mismatch! Will skip this row (",rowIdx,")")
153  continue
154  insertString = "INSERT INTO " + table + " VALUES ("
155  for idx in range(len(rowList)):
156  if idx > 0:
157  insertString += ", "
158  if "text" in columns[idx]:
159  fieldEntry = rowList[idx]
160  if table == "daq_channels" and "plane" in columns[idx]:
161  fieldEntry = rowList[idx].upper()
162  insertString += "\'" + fieldEntry + "\'"
163  else:
164  if "none" in rowList[idx]:
165  #print("Found none in column data, field:",columns[idx],", value: ",rowList[idx])
166  insertString += '0'
167  else:
168  insertString += "\'" +rowList[idx]+ "\'"
169  insertString += ")"
170  if table == "daq_channels":
171  print("idx:",rowIdx," -->",insertString)
172  dbCurs.execute(insertString)
173 
# Ok get down to extracting the info and copying to SQLite
do one_file $F done echo for F in find $TOP name CMakeLists txt print

Variable Documentation

list copyPostGresToSQLite.crtFEBChannelsColumns
Initial value:
1 = ['feb_id text',
2  'feb_channel integer',
3  'pedestal float',
4  'threshold_adjust integer',
5  'bias integer',
6  'hg integer',
7  'create_time text',
8  'update_user text',
9  'update_time text',
10  'create_user text',
11  'channel_id integer',
12  'feb_index integer',
13  'mac_address integer']

Definition at line 74 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.crtfebchannelsTable = "feb_channels"

Definition at line 185 of file copyPostGresToSQLite.py.

list copyPostGresToSQLite.daqChannelsColumns
Initial value:
1 = ['channel_id integer',
2  'wire_number integer',
3  'readout_board_id integer',
4  'chimney_number integer',
5  'readout_board_slot integer',
6  'channel_number integer',
7  'create_time text',
8  'create_user text',
9  'update_time text',
10  'update_user text',
11  'plane text',
12  'cable_label_number text',
13  'channel_type text']

Definition at line 29 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.daqChannelsTable = "daq_channels"

Definition at line 182 of file copyPostGresToSQLite.py.

tuple copyPostGresToSQLite.dataQuery = DataQuery(queryurl)

Definition at line 176 of file copyPostGresToSQLite.py.

tuple copyPostGresToSQLite.dbCurs = sqliteDB.cursor()

Definition at line 191 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.dbName = "icarus_hardware_prd"

Definition at line 180 of file copyPostGresToSQLite.py.

list copyPostGresToSQLite.flangesColumns
Initial value:
1 = ['flange_id integer',
2  'tpc_id text',
3  'chimney_number integer',
4  'flange_pos_at_chimney text',
5  'create_time text',
6  'update_user text',
7  'update_time text',
8  'create_user text',
9  'power_supply_ip_address text',
10  'power_supply_id integer']

Definition at line 43 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.flangesTable = "flanges"

Definition at line 183 of file copyPostGresToSQLite.py.

list copyPostGresToSQLite.pmtPlacementColumns
Initial value:
1 = ['pmt_id integer',
2  'pmt_sn text',
3  'sector_label text',
4  'ch_number integer',
5  'pmt_position_code integer',
6  'hv_cable_label text',
7  'signal_cable_label text',
8  'light_fiber_label text',
9  'digitizer_label text',
10  'digitizer_ch_number integer',
11  'hv_supply_label text',
12  'hv_supply_ch_number integer',
13  'create_time text',
14  'update_user text',
15  'update_time text',
16  'create_user text',
17  'pmt_in_tpc_plane text',
18  'channel_id integer',
19  'fragment_id integer']

Definition at line 54 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.pmtPlacementTable = "pmt_placements"

Definition at line 184 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.queryurl = "https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query"

Definition at line 174 of file copyPostGresToSQLite.py.

list copyPostGresToSQLite.readoutBoardsColumns
Initial value:
1 = ['readout_board_id integer',
2  'flange_id integer',
3  'chimney_number integer',
4  'tpc_id text',
5  'create_time text',
6  'create_user text',
7  'update_time text',
8  'update_user text',
9  'fragement_id text']

Definition at line 19 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.readoutBoardsTable = "readout_boards"

Definition at line 181 of file copyPostGresToSQLite.py.

tuple copyPostGresToSQLite.sqliteDB = sqlite3.connect("ChannelMapICARUS.db")

Definition at line 190 of file copyPostGresToSQLite.py.

list copyPostGresToSQLite.topcrtFEBColumns

Definition at line 88 of file copyPostGresToSQLite.py.

string copyPostGresToSQLite.topcrtfebTable = "crtfeb"

Definition at line 186 of file copyPostGresToSQLite.py.