00001 import coral
00002 from RecoLuminosity.LumiDB import nameDealer,dbUtil
00003
00004
00005
00006
00007
00008 def createTables(schema):
00009 '''
00010 create new tables if not exist
00011 revisions,revisions_id,luminorms,luminorms_entries,luminorms_entries_id,fillscheme
00012 '''
00013 try:
00014 created=[]
00015 db=dbUtil.dbUtil(schema)
00016 if not schema.existsTable(nameDealer.fillschemeTableName()):
00017 print 'creating fillscheme table'
00018 fillschemeTab=coral.TableDescription()
00019 fillschemeTab.setName( nameDealer.fillschemeTableName() )
00020 fillschemeTab.insertColumn( 'FILLSCHEME_ID','unsigned long long' )
00021 fillschemeTab.insertColumn( 'FILLSCHEMEPATTERN','string',128,False )
00022 fillschemeTab.insertColumn( 'CORRECTIONFACTOR','float' )
00023 fillschemeTab.setPrimaryKey( 'FILLSCHEME_ID' )
00024 db.createTable(fillschemeTab,withIdTable=True)
00025 created.append( nameDealer.fillschemeTableName() )
00026
00027 if not schema.existsTable(nameDealer.revisionTableName()):
00028 print 'creating revisions table'
00029 revisionsTab=coral.TableDescription()
00030 revisionsTab.setName( nameDealer.revisionTableName() )
00031 revisionsTab.insertColumn( 'REVISION_ID','unsigned long long')
00032 revisionsTab.insertColumn( 'BRANCH_ID','unsigned long long')
00033 revisionsTab.insertColumn( 'NAME', 'string',56,False)
00034 revisionsTab.insertColumn( 'BRANCH_NAME', 'string',56,False)
00035 revisionsTab.insertColumn( 'COMMENT', 'string',1024,False)
00036 revisionsTab.insertColumn( 'CTIME', 'time stamp',6)
00037 revisionsTab.setPrimaryKey( 'REVISION_ID' )
00038 revisionsTab.setUniqueConstraint(('NAME'))
00039 db.createTable(revisionsTab,withIdTable=True)
00040 created.append(nameDealer.revisionTableName())
00041
00042 if not schema.existsTable(nameDealer.luminormTableName()):
00043 print 'creating luminorms table'
00044 luminormsTab=coral.TableDescription()
00045 luminormsTab.setName( nameDealer.luminormTableName() )
00046 luminormsTab.insertColumn( 'DATA_ID','unsigned long long')
00047 luminormsTab.insertColumn( 'ENTRY_ID','unsigned long long')
00048 luminormsTab.insertColumn( 'ENTRY_NAME','string',56,False)
00049 luminormsTab.insertColumn( 'AMODETAG', 'string',28,False)
00050 luminormsTab.insertColumn( 'NORM_1', 'float')
00051 luminormsTab.insertColumn( 'EGEV_1', 'unsigned int')
00052 luminormsTab.insertColumn( 'NORM_2', 'float')
00053 luminormsTab.insertColumn( 'EGEV_2', 'unsigned int')
00054 luminormsTab.setPrimaryKey( 'DATA_ID' )
00055 db.createTable(luminormsTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
00056 created.append(nameDealer.luminormTableName())
00057
00058 if not schema.existsTable(nameDealer.lumidataTableName()):
00059 print 'creating lumidata table'
00060 lumidataTab=coral.TableDescription()
00061 lumidataTab.setName( nameDealer.lumidataTableName() )
00062 lumidataTab.insertColumn( 'DATA_ID','unsigned long long')
00063 lumidataTab.insertColumn( 'ENTRY_ID','unsigned long long')
00064 lumidataTab.insertColumn( 'ENTRY_NAME','string',56,False)
00065 lumidataTab.insertColumn( 'SOURCE', 'string',128,False)
00066 lumidataTab.insertColumn( 'RUNNUM', 'unsigned int')
00067 lumidataTab.insertColumn( 'NOMINALEGEV', 'float')
00068 lumidataTab.setPrimaryKey( 'DATA_ID' )
00069 db.createTable(lumidataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
00070 created.append(nameDealer.lumidataTableName())
00071
00072 if not schema.existsTable(nameDealer.lumisummaryv2TableName() ):
00073 print 'creating lumisummaryv2 table'
00074 summary=coral.TableDescription()
00075 summary.setName( nameDealer.lumisummaryv2TableName() )
00076 summary.insertColumn('DATA_ID','unsigned long long')
00077 summary.insertColumn('RUNNUM','unsigned int')
00078 summary.insertColumn('LUMILSNUM','unsigned int')
00079 summary.insertColumn('CMSLSNUM','unsigned int')
00080 summary.insertColumn('INSTLUMI','float')
00081 summary.insertColumn('INSTLUMIERROR','float')
00082 summary.insertColumn('INSTLUMIQUALITY','short')
00083 summary.insertColumn('BEAMSTATUS','string',28,False)
00084 summary.insertColumn('BEAMENERGY','float')
00085 summary.insertColumn('NUMORBIT','unsigned int')
00086 summary.insertColumn('STARTORBIT','unsigned int')
00087 summary.insertColumn('CMSBXINDEXBLOB','blob')
00088 summary.insertColumn('BEAMINTENSITYBLOB_1','blob')
00089 summary.insertColumn('BEAMINTENSITYBLOB_2','blob')
00090 summary.insertColumn('BXLUMIVALUE_OCC1','blob')
00091 summary.insertColumn('BXLUMIVALUE_OCC2','blob')
00092 summary.insertColumn('BXLUMIVALUE_ET','blob')
00093 summary.insertColumn('BXLUMIERROR_OCC1','blob')
00094 summary.insertColumn('BXLUMIERROR_OCC2','blob')
00095 summary.insertColumn('BXLUMIERROR_ET','blob')
00096 summary.insertColumn('BXLUMIQUALITY_OCC1','blob')
00097 summary.insertColumn('BXLUMIQUALITY_OCC2','blob')
00098 summary.insertColumn('BXLUMIQUALITY_ET','blob')
00099 summary.setPrimaryKey(('DATA_ID','LUMILSNUM'))
00100 db.createTable(summary,withIdTable=False)
00101 created.append(nameDealer.lumisummaryv2TableName())
00102
00103
00104
00105
00106 if not schema.existsTable(nameDealer.cmsrunsummaryTableName()):
00107 print 'creating cmsrunsummary table'
00108 cmsrunsummary=coral.TableDescription()
00109 cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() )
00110 cmsrunsummary.insertColumn('RUNNUM','unsigned int')
00111 cmsrunsummary.insertColumn('HLTKEY','string',128,False)
00112 cmsrunsummary.insertColumn('L1KEY','string',128,False)
00113 cmsrunsummary.insertColumn('FILLNUM','unsigned int')
00114 cmsrunsummary.insertColumn('SEQUENCE','string',56,False)
00115 cmsrunsummary.insertColumn('STARTTIME','time stamp',6)
00116 cmsrunsummary.insertColumn('STOPTIME','time stamp',6)
00117 cmsrunsummary.insertColumn('EGEV','unsigned int')
00118 cmsrunsummary.insertColumn('AMODETAG','string',28,False)
00119 cmsrunsummary.insertColumn('FILLSCHEME','string',128,False)
00120 cmsrunsummary.insertColumn('NCOLLIDINGBUNCHES','usigned int')
00121 cmsrunsummary.setPrimaryKey('RUNNUM')
00122 db.createTable(cmsrunsummary,withIdTable=False)
00123 created.append(nameDealer.cmsrunsummaryTableName())
00124
00125
00126
00127 if not schema.existsTable(nameDealer.trghltMapTableName()):
00128 print 'creating trghltmap table'
00129 trghlt=coral.TableDescription()
00130 trghlt.setName( nameDealer.trghltMapTableName() )
00131 trghlt.insertColumn( 'HLTKEY','string',128,False )
00132 trghlt.insertColumn( 'HLTPATHNAME','string',256,False )
00133 trghlt.insertColumn( 'L1SEED','string' ,1024,False)
00134 trghlt.setNotNullConstraint('HLTKEY',True)
00135 trghlt.setNotNullConstraint('HLTPATHNAME',True)
00136 trghlt.setNotNullConstraint('L1SEED',True)
00137 db.createTable(trghlt,withIdTable=False)
00138 created.append(nameDealer.trghltMapTableName())
00139 if not schema.existsTable(nameDealer.trgdataTableName()):
00140 print 'creating trgdata table'
00141 trgdataTab=coral.TableDescription()
00142 trgdataTab.setName( nameDealer.trgdataTableName() )
00143 trgdataTab.insertColumn( 'DATA_ID','unsigned long long')
00144 trgdataTab.insertColumn( 'ENTRY_ID','unsigned long long')
00145 trgdataTab.insertColumn( 'ENTRY_NAME','string',56,False)
00146 trgdataTab.insertColumn( 'SOURCE', 'string',128,False)
00147 trgdataTab.insertColumn( 'RUNNUM', 'unsigned int')
00148 trgdataTab.insertColumn( 'BITZERONAME', 'string',56,False)
00149 trgdataTab.insertColumn( 'BITNAMECLOB', 'string',6000)
00150 trgdataTab.setPrimaryKey( 'DATA_ID' )
00151 db.createTable(trgdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
00152 created.append(nameDealer.trgdataTableName())
00153 if not schema.existsTable(nameDealer.lstrgTableName()):
00154 print 'creating lstrg table'
00155 lstrgTab=coral.TableDescription()
00156 lstrgTab.setName( nameDealer.lstrgTableName() )
00157 lstrgTab.insertColumn( 'DATA_ID','unsigned long long')
00158 lstrgTab.insertColumn( 'RUNNUM', 'unsigned int')
00159 lstrgTab.insertColumn( 'CMSLSNUM', 'unsigned int')
00160 lstrgTab.insertColumn( 'DEADTIMECOUNT', 'unsigned long long')
00161 lstrgTab.insertColumn( 'BITZEROCOUNT', 'unsigned int')
00162 lstrgTab.insertColumn( 'BITZEROPRESCALE', 'unsigned int')
00163 lstrgTab.insertColumn( 'DEADFRAC', 'float')
00164 lstrgTab.insertColumn( 'PRESCALEBLOB', 'blob')
00165 lstrgTab.insertColumn( 'TRGCOUNTBLOB', 'blob')
00166 lstrgTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') )
00167 db.createTable(lstrgTab,withIdTable=False)
00168 created.append( nameDealer.lstrgTableName() )
00169
00170 if not schema.existsTable(nameDealer.hltdataTableName()):
00171 print 'creating hltdata table'
00172 hltdataTab=coral.TableDescription()
00173 hltdataTab.setName( nameDealer.hltdataTableName() )
00174 hltdataTab.insertColumn( 'DATA_ID','unsigned long long')
00175 hltdataTab.insertColumn( 'ENTRY_ID','unsigned long long')
00176 hltdataTab.insertColumn( 'ENTRY_NAME','string',56,False)
00177 hltdataTab.insertColumn( 'RUNNUM', 'unsigned int')
00178 hltdataTab.insertColumn( 'SOURCE', 'string',128,False)
00179 hltdataTab.insertColumn( 'NPATH', 'unsigned int')
00180 hltdataTab.insertColumn( 'PATHNAMECLOB', 'string',6000)
00181 hltdataTab.setPrimaryKey( 'DATA_ID' )
00182 db.createTable(hltdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
00183 created.append(nameDealer.hltTableName())
00184
00185 if not schema.existsTable(nameDealer.lshltTableName()):
00186 print 'creating lshlt table'
00187 lshltTab=coral.TableDescription()
00188 lshltTab.setName( nameDealer.lshltTableName() )
00189 lshltTab.insertColumn( 'DATA_ID','unsigned long long')
00190 lshltTab.insertColumn( 'RUNNUM', 'unsigned int')
00191 lshltTab.insertColumn( 'CMSLSNUM', 'unsigned int')
00192 lshltTab.insertColumn( 'PRESCALEBLOB', 'blob')
00193 lshltTab.insertColumn( 'HLTCOUNTBLOB', 'blob')
00194 lshltTab.insertColumn( 'HLTACCEPTBLOB', 'blob')
00195 db.createTable(lshltTab,withIdTable=False)
00196 lshltTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') )
00197 created.append(nameDealer.lshltTableName())
00198
00199
00200 if not schema.existsTable(nameDealer.lumivalidationTableName()):
00201 print 'creating lumivalidation table'
00202 lumivalidation=coral.TableDescription()
00203 lumivalidation.setName( nameDealer.lumivalidationTableName() )
00204 lumivalidation.insertColumn( 'RUNNUM','unsigned int' )
00205 lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' )
00206 lumivalidation.insertColumn( 'FLAG','string',28,False )
00207 lumivalidation.insertColumn( 'COMMENT','string',1024,False )
00208 lumivalidation.setPrimaryKey( ('RUNNUM','CMSLSNUM') )
00209 lumivalidation.setNotNullConstraint('FLAG',True)
00210 db.createTable(lumivalidation,withIdTable=False)
00211 created.append(nameDealer.lumivalidationTableName())
00212 return created
00213 except :
00214 raise
00215
00216
00217
00218
00219
00220
00221
00222 def dropTables(schema,tablelist):
00223 try:
00224 db=dbUtil.dbUtil(schema)
00225 for tablename in tablelist:
00226 if tablename in [nameDealer.luminormTableName(),nameDealer.lumidataTableName(),nameDealer.trgdataTableName(),nameDealer.hltdataTableName()]:
00227 db.dropTable( nameDealer.idTableName(tablename) )
00228 db.dropTable( nameDealer.entryTableName(tablename) )
00229 db.dropTable( nameDealer.revmapTableName(tablename) )
00230 if tablename in [nameDealer.trgTableName(),nameDealer.lumisummaryTableName(),nameDealer.lumisummaryv2TableName(),nameDealer.lumidetailTableName(),nameDealer.hltTableName()]:
00231 db.dropTable( nameDealer.idTableName(tablename) )
00232 db.dropTable( tablename )
00233 except :
00234 raise
00235
00236 def createOldSchema(schema):
00237 '''
00238 create tables of lumidb1 if not exist
00239 '''
00240 try:
00241 created=[]
00242 db=dbUtil.dbUtil(schema)
00243 if not schema.existsTable(nameDealer.lumivalidationTableName()):
00244 lumivalidation=coral.TableDescription()
00245 lumivalidation.setName( nameDealer.lumivalidationTableName() )
00246 lumivalidation.insertColumn( 'RUNNUM','unsigned int' )
00247 lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' )
00248 lumivalidation.insertColumn( 'FLAG','string',28,False )
00249 lumivalidation.insertColumn( 'COMMENT','string',1024,False )
00250 lumivalidation.setPrimaryKey(('RUNNUM','CMSLSNUM'))
00251 lumivalidation.setNotNullConstraint('FLAG',True)
00252 db.createTable(lumivalidation,withIdTable=False)
00253 created.append(nameDealer.lumivalidationTableName())
00254
00255 if not schema.existsTable(nameDealer.cmsrunsummaryTableName()):
00256 cmsrunsummary=coral.TableDescription()
00257 cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() )
00258 cmsrunsummary.insertColumn('RUNNUM','unsigned int')
00259 cmsrunsummary.insertColumn('HLTKEY','string',128,False)
00260 cmsrunsummary.insertColumn('FILLNUM','unsigned int')
00261 cmsrunsummary.insertColumn('SEQUENCE','string',56,False)
00262 cmsrunsummary.insertColumn('STARTTIME','time stamp',6)
00263 cmsrunsummary.insertColumn('STOPTIME','time stamp',6)
00264 cmsrunsummary.setPrimaryKey('RUNNUM')
00265 cmsrunsummary.setNotNullConstraint('HLTKEY',True)
00266 cmsrunsummary.setNotNullConstraint('FILLNUM',True)
00267 cmsrunsummary.setNotNullConstraint('SEQUENCE',True)
00268 cmsrunsummary.createIndex('cmsrunsummary_fillnum',('FILLNUM'))
00269 cmsrunsummary.createIndex('cmsrunsummary_startime',('STARTTIME'))
00270 db.createTable(cmsrunsummary,withIdTable=False)
00271 created.append(nameDealer.cmsrunsummaryTableName())
00272
00273 if not schema.existsTable(nameDealer.lumisummaryTableName()):
00274 summary=coral.TableDescription()
00275 summary.setName( nameDealer.lumisummaryTableName() )
00276 summary.insertColumn('LUMISUMMARY_ID','unsigned long long')
00277 summary.insertColumn('RUNNUM','unsigned int')
00278 summary.insertColumn('CMSLSNUM','unsigned int')
00279 summary.insertColumn('LUMILSNUM','unsigned int')
00280 summary.insertColumn('LUMIVERSION','string',28,False)
00281 summary.insertColumn('DTNORM','float')
00282 summary.insertColumn('LHCNORM','float')
00283 summary.insertColumn('CMSALIVE','short')
00284 summary.insertColumn('INSTLUMI','float')
00285 summary.insertColumn('INSTLUMIERROR','float')
00286 summary.insertColumn('INSTLUMIQUALITY','short')
00287 summary.insertColumn('BEAMSTATUS','string',28,False)
00288 summary.insertColumn('BEAMENERGY','float')
00289 summary.insertColumn('NUMORBIT','unsigned int')
00290 summary.insertColumn('STARTORBIT','unsigned int')
00291 summary.insertColumn('LUMISECTIONQUALITY','short')
00292 summary.insertColumn('CMSBXINDEXBLOB','blob')
00293 summary.insertColumn('BEAMINTENSITYBLOB_1','blob')
00294 summary.insertColumn('BEAMINTENSITYBLOB_2','blob')
00295 summary.setPrimaryKey('LUMISUMMARY_ID')
00296 summary.setNotNullConstraint('RUNNUM',True)
00297 summary.setNotNullConstraint('CMSLSNUM',True)
00298 summary.setNotNullConstraint('LUMILSNUM',True)
00299 summary.setNotNullConstraint('CMSALIVE',True)
00300 summary.setNotNullConstraint('LUMIVERSION',True)
00301 summary.setNotNullConstraint('DTNORM',True)
00302 summary.setNotNullConstraint('LHCNORM',True)
00303 summary.setNotNullConstraint('INSTLUMI',True)
00304 summary.setNotNullConstraint('INSTLUMIERROR',True)
00305 summary.setNotNullConstraint('INSTLUMIQUALITY',True)
00306 summary.setNotNullConstraint('STARTORBIT',True)
00307 summary.setNotNullConstraint('NUMORBIT',True)
00308 summary.setNotNullConstraint('LUMISECTIONQUALITY',True)
00309 summary.setNotNullConstraint('BEAMENERGY',True)
00310 summary.setNotNullConstraint('BEAMSTATUS',True)
00311 summary.setUniqueConstraint(('RUNNUM','LUMIVERSION','LUMILSNUM'))
00312 summary.createIndex('lumisummary_runnum',('RUNNUM'))
00313 db.createTable(summary,withIdTable=True)
00314 created.append(nameDealer.lumisummaryTableName())
00315
00316 if not schema.existsTable(nameDealer.lumidetailTableName()):
00317 detail=coral.TableDescription()
00318 detail.setName( nameDealer.lumidetailTableName() )
00319 detail.insertColumn('LUMIDETAIL_ID','unsigned long long')
00320 detail.insertColumn('LUMISUMMARY_ID','unsigned long long')
00321 detail.insertColumn('BXLUMIVALUE','blob')
00322 detail.insertColumn('BXLUMIERROR','blob')
00323 detail.insertColumn('BXLUMIQUALITY','blob')
00324 detail.insertColumn('ALGONAME','string',28,False)
00325 detail.setPrimaryKey('LUMIDETAIL_ID')
00326 detail.createForeignKey('DETAILSOURCE','LUMISUMMARY_ID',nameDealer.lumisummaryTableName(),'LUMISUMMARY_ID')
00327 detail.setNotNullConstraint('BXLUMIVALUE',True)
00328 detail.setNotNullConstraint('BXLUMIERROR',True)
00329 detail.setNotNullConstraint('BXLUMIQUALITY',True)
00330 detail.setNotNullConstraint('ALGONAME',True)
00331 detail.setUniqueConstraint(('LUMISUMMARY_ID','ALGONAME'))
00332 db.createTable(detail,withIdTable=True)
00333 created.append(nameDealer.lumidetailTableName())
00334
00335 if not schema.existsTable(nameDealer.trgTableName()):
00336 trg=coral.TableDescription()
00337 trg.setName( nameDealer.trgTableName() )
00338 trg.insertColumn('TRG_ID','unsigned long long')
00339 trg.insertColumn('RUNNUM','unsigned int')
00340 trg.insertColumn('CMSLSNUM','unsigned int')
00341 trg.insertColumn('BITNUM','unsigned int')
00342 trg.insertColumn('BITNAME','string',56,False)
00343 trg.insertColumn('TRGCOUNT','unsigned int')
00344 trg.insertColumn('DEADTIME','unsigned long long')
00345 trg.insertColumn('PRESCALE','unsigned int')
00346 trg.setNotNullConstraint('RUNNUM',True)
00347 trg.setNotNullConstraint('CMSLSNUM',True)
00348 trg.setNotNullConstraint('BITNUM',True)
00349 trg.setNotNullConstraint('BITNAME',True)
00350 trg.setNotNullConstraint('TRGCOUNT',True)
00351 trg.setNotNullConstraint('DEADTIME',True)
00352 trg.setNotNullConstraint('PRESCALE',True)
00353 trg.setPrimaryKey('TRG_ID')
00354 trg.createIndex('trg_runnum',('RUNNUM'))
00355 db.createTable(trg,withIdTable=True)
00356 created.append( nameDealer.trgTableName() )
00357
00358 if not schema.existsTable( nameDealer.hltTableName() ):
00359 hlt=coral.TableDescription()
00360 hlt.setName( nameDealer.hltTableName() )
00361 hlt.insertColumn( 'HLT_ID','unsigned long long')
00362 hlt.insertColumn( 'RUNNUM','unsigned int')
00363 hlt.insertColumn( 'CMSLSNUM','unsigned int')
00364 hlt.insertColumn( 'PATHNAME','string',256,False)
00365 hlt.insertColumn( 'INPUTCOUNT','unsigned int')
00366 hlt.insertColumn( 'ACCEPTCOUNT','unsigned int')
00367 hlt.insertColumn( 'PRESCALE','unsigned int')
00368 hlt.setPrimaryKey( 'HLT_ID' )
00369 hlt.setNotNullConstraint('RUNNUM',True)
00370 hlt.setNotNullConstraint('CMSLSNUM',True)
00371 hlt.setNotNullConstraint('PATHNAME',True)
00372 hlt.setNotNullConstraint('INPUTCOUNT',True)
00373 hlt.setNotNullConstraint('ACCEPTCOUNT',True)
00374 hlt.setNotNullConstraint('PRESCALE',True)
00375 hlt.createIndex('hlt_runnum',('RUNNUM'))
00376 db.createTable(hlt,withIdTable=True)
00377 created.append( nameDealer.hltTableName() )
00378
00379 if not schema.existsTable( nameDealer.trghltMapTableName() ):
00380 trghlt=coral.TableDescription()
00381 trghlt.setName( nameDealer.trghltMapTableName() )
00382 trghlt.insertColumn( 'HLTKEY','string',128,False )
00383 trghlt.insertColumn( 'HLTPATHNAME','string',256,False )
00384 trghlt.insertColumn( 'L1SEED','string',1024,false )
00385 trghlt.setNotNullConstraint('HLTKEY',True)
00386 trghlt.setNotNullConstraint('HLTPATHNAME',True)
00387 trghlt.setNotNullConstraint('L1SEED',True)
00388 db.createTable(trghlt,withIdTable=False)
00389 created.append( nameDealer.trghltMapTableName() )
00390 return created
00391 except:
00392 raise
00393
00394
00395
00396
00397
00398
00399 def oldToNew(schema):
00400 '''
00401 modify old tables:cmsrunsummary
00402 alter table cmsrunsummary add column(l1key string,egev unsigned int,amodetag string)
00403 '''
00404 try:
00405 tableHandle=schema.tableHandle(nameDealer.cmsrunsummaryTableName())
00406 tableHandle.schemaEditor().insertColumn('L1KEY','string',128,False)
00407 tableHandle.schemaEditor().insertColumn('EGEV','unsigned int')
00408 tableHandle.schemaEditor().insertColumn('AMODETAG','string',28,False)
00409 createTables(schema)
00410 except:
00411 raise
00412
00413 def newToOld(schema):
00414 try:
00415 dropTables(schema,['REVISIONS','LUMINORMS','LUMIDATA','LUMISUMMARYV2','TRGDATA','LSTRG','HLTDATA','LSHLT'])
00416 tableHandle=schema.tableHandle(nameDealer.cmsrunsummaryTableName())
00417 ncol=tableHandle.description().numberOfColumns()
00418 todrop=[]
00419 for i in range(ncol):
00420 colname=tableHandle.description().columnDescription(i).name()
00421 if colname in ['L1KEY','EGEV','AMODETAG']:
00422 todrop.append(colname)
00423 for colname in todrop:
00424 tableHandle.schemaEditor().dropColumn(colname)
00425 except :
00426 raise
00427
00428
00429
00430
00431
00432
00433
00434 def createIndices(schema):
00435 '''
00436 '''
00437 pass
00438
00439
00440
00441 def dropIndices(schema):
00442 '''
00443 '''
00444 pass
00445 def describeIndices(schema):
00446 '''
00447 '''
00448 pass
00449 def createFKConstraints(schema):
00450 '''
00451 '''
00452 pass
00453 def dropFKConstrains(schema):
00454 '''
00455 '''
00456 pass
00457 def createNULLConstraints(schema):
00458 '''
00459 '''
00460
00461
00462
00463 pass
00464 def dropNULLConstraints(schema):
00465 '''
00466 '''
00467 pass
00468
00469 def createUniqueConstraints(schema):
00470 '''
00471 '''
00472 try:
00473 revtable=schema.tableHandle(nameDealer.revisionTableName())
00474 revtable.schemaEditor().setUniqueConstraint('NAME','revisions_name_uc')
00475 except:
00476 raise
00477 def dropUNIQUEConstraints(schema):
00478 '''
00479 '''
00480 pass
00481
00482 def describe(schema):
00483 '''
00484 '''
00485 pass
00486
00487 if __name__ == "__main__":
00488 import sessionManager
00489 myconstr='oracle://devdb10/cms_xiezhen_dev'
00490 authpath='/afs/cern.ch/user/x/xiezhen'
00491
00492 svc=sessionManager.sessionManager(myconstr,authpath=authpath,debugON=False)
00493 session=svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
00494 schema=session.nominalSchema()
00495 session.transaction().start(False)
00496 tables=createTables(schema)
00497 if len(tables)==0:
00498 dropTables(schema,nameDealer.schemaV2Tables())
00499 else:
00500 dropTables(schema,tables)
00501 dropTables(schema,nameDealer.commonTables())
00502
00503
00504
00505
00506
00507 session.transaction().start(False)
00508 tables=createOldSchema(schema)
00509 oldToNew(schema)
00510 print 'created old ',tables
00511 session.transaction().commit()
00512 del session