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