12 from __future__
import print_function
13 import sys, os, datetime
16 from DataLoader3
import DataLoader, DataQuery
19 readoutBoardsColumns = [
'readout_board_id integer',
21 'chimney_number integer',
29 daqChannelsColumns = [
'channel_id integer',
30 'wire_number integer',
31 'readout_board_id integer',
32 'chimney_number integer',
33 'readout_board_slot integer',
34 'channel_number integer',
40 'cable_label_number text',
43 flangesColumns = [
'flange_id integer',
45 'chimney_number integer',
46 'flange_pos_at_chimney text',
51 'power_supply_ip_address text',
52 'power_supply_id integer']
54 pmtPlacementColumns = [
'pmt_id integer',
58 'pmt_position_code integer',
59 'hv_cable_label text',
60 'signal_cable_label text',
61 'light_fiber_label text',
62 'digitizer_label text',
63 'digitizer_ch_number integer',
64 'hv_supply_label text',
65 'hv_supply_ch_number integer',
70 'pmt_in_tpc_plane text',
72 'fragment_id integer']
74 crtFEBChannelsColumns = [
'feb_id text',
75 'feb_channel integer',
77 'threshold_adjust integer',
86 'mac_address integer']
88 topcrtFEBColumns = [
'feb_barcode text',
132 def copyTable(postGres, dbCurs, dbName, table, columns):
133 createString =
"CREATE TABLE " + table +
" ("
135 for columnIdx
in range(len(columns)):
138 createString += columns[columnIdx]
144 dbCurs.execute(createString)
146 query = postGres.query(database=dbName, table=table, columns=
"*")
148 for rowIdx
in range(len(query)):
149 rowList = query[rowIdx].split(
',')
150 if len(rowList) != len(columns):
151 print(
"Length mismatch! Will skip this row (",rowIdx,
")")
153 insertString =
"INSERT INTO " + table +
" VALUES ("
154 for idx
in range(len(rowList)):
157 if "text" in columns[idx]:
158 fieldEntry = rowList[idx]
159 if table ==
"daq_channels" and "plane" in columns[idx]:
160 fieldEntry = rowList[idx].upper()
161 insertString +=
"\'" + fieldEntry +
"\'"
163 if "none" in rowList[idx]:
167 insertString +=
"\'" +rowList[idx]+
"\'"
169 if table ==
"daq_channels":
170 print(
"idx:",rowIdx,
" -->",insertString)
171 dbCurs.execute(insertString)
174 queryurl =
"https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query"
180 dbName =
"icarus_hardware_prd"
181 readoutBoardsTable =
"readout_boards"
182 daqChannelsTable =
"daq_channels"
183 flangesTable =
"flanges"
184 pmtPlacementTable =
"pmt_placements"
185 crtfebchannelsTable=
"feb_channels"
186 topcrtfebTable =
"crtfeb"
190 sqliteDB = sqlite3.connect(
"ChannelMapICARUS.db")
191 dbCurs = sqliteDB.cursor()
195 copyTable(dataQuery, dbCurs, dbName, readoutBoardsTable, readoutBoardsColumns)
197 copyTable(dataQuery, dbCurs, dbName, daqChannelsTable, daqChannelsColumns)
199 copyTable(dataQuery, dbCurs, dbName, flangesTable, flangesColumns)
201 copyTable(dataQuery, dbCurs, dbName, pmtPlacementTable, pmtPlacementColumns)
203 copyTable(dataQuery, dbCurs, dbName, crtfebchannelsTable, crtFEBChannelsColumns)
205 copyTable(dataQuery, dbCurs, dbName, topcrtfebTable, topcrtFEBColumns)
do one_file $F done echo for F in find $TOP name CMakeLists txt print