def dropTables(schema,tablelist): try: db=dbUtil.dbUtil(schema) for tablename in tablelist: if tablename in [nameDealer.luminormTableName(),nameDealer.lumidataTableName(),nameDealer.trgdataTableName(),nameDealer.hltdataTableName()]: db.dropTable( nameDealer.idTableName(tablename) ) db.dropTable( nameDealer.entryTableName(tablename) ) db.dropTable( nameDealer.revmapTableName(tablename) ) if tablename in [nameDealer.trgTableName(),nameDealer.lumisummaryTableName(),nameDealer.lumisummaryv2TableName(),nameDealer.lumidetailTableName(),nameDealer.hltTableName()]: db.dropTable( nameDealer.idTableName(tablename) ) db.dropTable( tablename ) except : raise
def dropTables(schema, tablelist): try: db = dbUtil.dbUtil(schema) for tablename in tablelist: if tablename in [ nameDealer.luminormTableName(), nameDealer.lumidataTableName(), nameDealer.trgdataTableName(), nameDealer.hltdataTableName() ]: db.dropTable(nameDealer.idTableName(tablename)) db.dropTable(nameDealer.entryTableName(tablename)) db.dropTable(nameDealer.revmapTableName(tablename)) if tablename in [ nameDealer.trgTableName(), nameDealer.lumisummaryTableName(), nameDealer.lumisummaryv2TableName(), nameDealer.lumidetailTableName(), nameDealer.hltTableName() ]: db.dropTable(nameDealer.idTableName(tablename)) db.dropTable(tablename) except: raise
def createTables(schema): ''' create new tables if not exist revisions,revisions_id,luminorms,luminorms_entries,luminorms_entries_id,fillscheme ''' try: created=[] db=dbUtil.dbUtil(schema) if not schema.existsTable(nameDealer.fillschemeTableName()): print('creating fillscheme table') fillschemeTab=coral.TableDescription() fillschemeTab.setName( nameDealer.fillschemeTableName() ) fillschemeTab.insertColumn( 'FILLSCHEME_ID','unsigned long long' ) fillschemeTab.insertColumn( 'FILLSCHEMEPATTERN','string',128,False ) fillschemeTab.insertColumn( 'CORRECTIONFACTOR','float' ) fillschemeTab.setPrimaryKey( 'FILLSCHEME_ID' ) db.createTable(fillschemeTab,withIdTable=True) created.append( nameDealer.fillschemeTableName() ) if not schema.existsTable(nameDealer.revisionTableName()): print('creating revisions table') revisionsTab=coral.TableDescription() revisionsTab.setName( nameDealer.revisionTableName() ) revisionsTab.insertColumn( 'REVISION_ID','unsigned long long') revisionsTab.insertColumn( 'BRANCH_ID','unsigned long long') revisionsTab.insertColumn( 'NAME', 'string',56,False) revisionsTab.insertColumn( 'BRANCH_NAME', 'string',56,False) revisionsTab.insertColumn( 'COMMENT', 'string',1024,False) revisionsTab.insertColumn( 'CTIME', 'time stamp',6) revisionsTab.setPrimaryKey( 'REVISION_ID' ) revisionsTab.setUniqueConstraint(('NAME')) db.createTable(revisionsTab,withIdTable=True) created.append(nameDealer.revisionTableName()) if not schema.existsTable(nameDealer.luminormTableName()): print('creating luminorms table') luminormsTab=coral.TableDescription() luminormsTab.setName( nameDealer.luminormTableName() ) luminormsTab.insertColumn( 'DATA_ID','unsigned long long') luminormsTab.insertColumn( 'ENTRY_ID','unsigned long long') luminormsTab.insertColumn( 'ENTRY_NAME','string',56,False) luminormsTab.insertColumn( 'AMODETAG', 'string',28,False) luminormsTab.insertColumn( 'NORM_1', 'float') luminormsTab.insertColumn( 'EGEV_1', 'unsigned int') luminormsTab.insertColumn( 'NORM_2', 'float') luminormsTab.insertColumn( 'EGEV_2', 'unsigned int') luminormsTab.setPrimaryKey( 'DATA_ID' ) db.createTable(luminormsTab,withIdTable=True,withEntryTables=True,withRevMapTable=True) created.append(nameDealer.luminormTableName()) if not schema.existsTable(nameDealer.lumidataTableName()): print('creating lumidata table') lumidataTab=coral.TableDescription() lumidataTab.setName( nameDealer.lumidataTableName() ) lumidataTab.insertColumn( 'DATA_ID','unsigned long long') lumidataTab.insertColumn( 'ENTRY_ID','unsigned long long') lumidataTab.insertColumn( 'ENTRY_NAME','string',56,False) lumidataTab.insertColumn( 'SOURCE', 'string',128,False) lumidataTab.insertColumn( 'RUNNUM', 'unsigned int') lumidataTab.insertColumn( 'NOMINALEGEV', 'float') lumidataTab.setPrimaryKey( 'DATA_ID' ) db.createTable(lumidataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True) created.append(nameDealer.lumidataTableName()) if not schema.existsTable(nameDealer.lumisummaryv2TableName() ): print('creating lumisummaryv2 table') summary=coral.TableDescription() summary.setName( nameDealer.lumisummaryv2TableName() ) summary.insertColumn('DATA_ID','unsigned long long') summary.insertColumn('RUNNUM','unsigned int') summary.insertColumn('LUMILSNUM','unsigned int') summary.insertColumn('CMSLSNUM','unsigned int') summary.insertColumn('INSTLUMI','float') summary.insertColumn('INSTLUMIERROR','float') summary.insertColumn('INSTLUMIQUALITY','short') summary.insertColumn('BEAMSTATUS','string',28,False) summary.insertColumn('BEAMENERGY','float') summary.insertColumn('NUMORBIT','unsigned int') summary.insertColumn('STARTORBIT','unsigned int') summary.insertColumn('CMSBXINDEXBLOB','blob') summary.insertColumn('BEAMINTENSITYBLOB_1','blob') summary.insertColumn('BEAMINTENSITYBLOB_2','blob') summary.insertColumn('BXLUMIVALUE_OCC1','blob') summary.insertColumn('BXLUMIVALUE_OCC2','blob') summary.insertColumn('BXLUMIVALUE_ET','blob') summary.insertColumn('BXLUMIERROR_OCC1','blob') summary.insertColumn('BXLUMIERROR_OCC2','blob') summary.insertColumn('BXLUMIERROR_ET','blob') summary.insertColumn('BXLUMIQUALITY_OCC1','blob') summary.insertColumn('BXLUMIQUALITY_OCC2','blob') summary.insertColumn('BXLUMIQUALITY_ET','blob') summary.setPrimaryKey(('DATA_ID','LUMILSNUM')) db.createTable(summary,withIdTable=False) created.append(nameDealer.lumisummaryv2TableName()) # # This table exists in the old schema # if not schema.existsTable(nameDealer.cmsrunsummaryTableName()): print('creating cmsrunsummary table') cmsrunsummary=coral.TableDescription() cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() ) cmsrunsummary.insertColumn('RUNNUM','unsigned int') cmsrunsummary.insertColumn('HLTKEY','string',128,False) cmsrunsummary.insertColumn('L1KEY','string',128,False) cmsrunsummary.insertColumn('FILLNUM','unsigned int') cmsrunsummary.insertColumn('SEQUENCE','string',56,False) cmsrunsummary.insertColumn('STARTTIME','time stamp',6) cmsrunsummary.insertColumn('STOPTIME','time stamp',6) cmsrunsummary.insertColumn('EGEV','unsigned int') cmsrunsummary.insertColumn('AMODETAG','string',28,False) cmsrunsummary.insertColumn('FILLSCHEME','string',128,False) cmsrunsummary.insertColumn('NCOLLIDINGBUNCHES','usigned int') cmsrunsummary.setPrimaryKey('RUNNUM') db.createTable(cmsrunsummary,withIdTable=False) created.append(nameDealer.cmsrunsummaryTableName()) # # This table exists in the old schema # if not schema.existsTable(nameDealer.trghltMapTableName()): print('creating trghltmap table') trghlt=coral.TableDescription() trghlt.setName( nameDealer.trghltMapTableName() ) trghlt.insertColumn( 'HLTKEY','string',128,False ) trghlt.insertColumn( 'HLTPATHNAME','string',256,False ) trghlt.insertColumn( 'L1SEED','string' ,1024,False) trghlt.setNotNullConstraint('HLTKEY',True) trghlt.setNotNullConstraint('HLTPATHNAME',True) trghlt.setNotNullConstraint('L1SEED',True) db.createTable(trghlt,withIdTable=False) created.append(nameDealer.trghltMapTableName()) if not schema.existsTable(nameDealer.trgdataTableName()): print('creating trgdata table') trgdataTab=coral.TableDescription() trgdataTab.setName( nameDealer.trgdataTableName() ) trgdataTab.insertColumn( 'DATA_ID','unsigned long long') trgdataTab.insertColumn( 'ENTRY_ID','unsigned long long') trgdataTab.insertColumn( 'ENTRY_NAME','string',56,False) trgdataTab.insertColumn( 'SOURCE', 'string',128,False) trgdataTab.insertColumn( 'RUNNUM', 'unsigned int') trgdataTab.insertColumn( 'BITZERONAME', 'string',56,False) trgdataTab.insertColumn( 'BITNAMECLOB', 'string',6000) trgdataTab.setPrimaryKey( 'DATA_ID' ) db.createTable(trgdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True) created.append(nameDealer.trgdataTableName()) if not schema.existsTable(nameDealer.lstrgTableName()): print('creating lstrg table') lstrgTab=coral.TableDescription() lstrgTab.setName( nameDealer.lstrgTableName() ) lstrgTab.insertColumn( 'DATA_ID','unsigned long long') lstrgTab.insertColumn( 'RUNNUM', 'unsigned int') lstrgTab.insertColumn( 'CMSLSNUM', 'unsigned int') lstrgTab.insertColumn( 'DEADTIMECOUNT', 'unsigned long long') lstrgTab.insertColumn( 'BITZEROCOUNT', 'unsigned int') lstrgTab.insertColumn( 'BITZEROPRESCALE', 'unsigned int') lstrgTab.insertColumn( 'DEADFRAC', 'float') lstrgTab.insertColumn( 'PRESCALEBLOB', 'blob') lstrgTab.insertColumn( 'TRGCOUNTBLOB', 'blob') lstrgTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') ) db.createTable(lstrgTab,withIdTable=False) created.append( nameDealer.lstrgTableName() ) if not schema.existsTable(nameDealer.hltdataTableName()): print('creating hltdata table') hltdataTab=coral.TableDescription() hltdataTab.setName( nameDealer.hltdataTableName() ) hltdataTab.insertColumn( 'DATA_ID','unsigned long long') hltdataTab.insertColumn( 'ENTRY_ID','unsigned long long') hltdataTab.insertColumn( 'ENTRY_NAME','string',56,False) hltdataTab.insertColumn( 'RUNNUM', 'unsigned int') hltdataTab.insertColumn( 'SOURCE', 'string',128,False) hltdataTab.insertColumn( 'NPATH', 'unsigned int') hltdataTab.insertColumn( 'PATHNAMECLOB', 'string',6000) hltdataTab.setPrimaryKey( 'DATA_ID' ) db.createTable(hltdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True) created.append(nameDealer.hltTableName()) if not schema.existsTable(nameDealer.lshltTableName()): print('creating lshlt table') lshltTab=coral.TableDescription() lshltTab.setName( nameDealer.lshltTableName() ) lshltTab.insertColumn( 'DATA_ID','unsigned long long') lshltTab.insertColumn( 'RUNNUM', 'unsigned int') lshltTab.insertColumn( 'CMSLSNUM', 'unsigned int') lshltTab.insertColumn( 'PRESCALEBLOB', 'blob') lshltTab.insertColumn( 'HLTCOUNTBLOB', 'blob') lshltTab.insertColumn( 'HLTACCEPTBLOB', 'blob') db.createTable(lshltTab,withIdTable=False) lshltTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') ) created.append(nameDealer.lshltTableName()) if not schema.existsTable(nameDealer.lumivalidationTableName()): print('creating lumivalidation table') lumivalidation=coral.TableDescription() lumivalidation.setName( nameDealer.lumivalidationTableName() ) lumivalidation.insertColumn( 'RUNNUM','unsigned int' ) lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' ) lumivalidation.insertColumn( 'FLAG','string',28,False ) lumivalidation.insertColumn( 'COMMENT','string',1024,False ) lumivalidation.setPrimaryKey( ('RUNNUM','CMSLSNUM') ) lumivalidation.setNotNullConstraint('FLAG',True) db.createTable(lumivalidation,withIdTable=False) created.append(nameDealer.lumivalidationTableName()) return created except : raise
def createTables(schema): ''' create new tables if not exist revisions,revisions_id,luminorms,luminorms_entries,luminorms_entries_id,fillscheme ''' try: created = [] db = dbUtil.dbUtil(schema) if not schema.existsTable(nameDealer.fillschemeTableName()): print('creating fillscheme table') fillschemeTab = coral.TableDescription() fillschemeTab.setName(nameDealer.fillschemeTableName()) fillschemeTab.insertColumn('FILLSCHEME_ID', 'unsigned long long') fillschemeTab.insertColumn('FILLSCHEMEPATTERN', 'string', 128, False) fillschemeTab.insertColumn('CORRECTIONFACTOR', 'float') fillschemeTab.setPrimaryKey('FILLSCHEME_ID') db.createTable(fillschemeTab, withIdTable=True) created.append(nameDealer.fillschemeTableName()) if not schema.existsTable(nameDealer.revisionTableName()): print('creating revisions table') revisionsTab = coral.TableDescription() revisionsTab.setName(nameDealer.revisionTableName()) revisionsTab.insertColumn('REVISION_ID', 'unsigned long long') revisionsTab.insertColumn('BRANCH_ID', 'unsigned long long') revisionsTab.insertColumn('NAME', 'string', 56, False) revisionsTab.insertColumn('BRANCH_NAME', 'string', 56, False) revisionsTab.insertColumn('COMMENT', 'string', 1024, False) revisionsTab.insertColumn('CTIME', 'time stamp', 6) revisionsTab.setPrimaryKey('REVISION_ID') revisionsTab.setUniqueConstraint(('NAME')) db.createTable(revisionsTab, withIdTable=True) created.append(nameDealer.revisionTableName()) if not schema.existsTable(nameDealer.luminormTableName()): print('creating luminorms table') luminormsTab = coral.TableDescription() luminormsTab.setName(nameDealer.luminormTableName()) luminormsTab.insertColumn('DATA_ID', 'unsigned long long') luminormsTab.insertColumn('ENTRY_ID', 'unsigned long long') luminormsTab.insertColumn('ENTRY_NAME', 'string', 56, False) luminormsTab.insertColumn('AMODETAG', 'string', 28, False) luminormsTab.insertColumn('NORM_1', 'float') luminormsTab.insertColumn('EGEV_1', 'unsigned int') luminormsTab.insertColumn('NORM_2', 'float') luminormsTab.insertColumn('EGEV_2', 'unsigned int') luminormsTab.setPrimaryKey('DATA_ID') db.createTable(luminormsTab, withIdTable=True, withEntryTables=True, withRevMapTable=True) created.append(nameDealer.luminormTableName()) if not schema.existsTable(nameDealer.lumidataTableName()): print('creating lumidata table') lumidataTab = coral.TableDescription() lumidataTab.setName(nameDealer.lumidataTableName()) lumidataTab.insertColumn('DATA_ID', 'unsigned long long') lumidataTab.insertColumn('ENTRY_ID', 'unsigned long long') lumidataTab.insertColumn('ENTRY_NAME', 'string', 56, False) lumidataTab.insertColumn('SOURCE', 'string', 128, False) lumidataTab.insertColumn('RUNNUM', 'unsigned int') lumidataTab.insertColumn('NOMINALEGEV', 'float') lumidataTab.setPrimaryKey('DATA_ID') db.createTable(lumidataTab, withIdTable=True, withEntryTables=True, withRevMapTable=True) created.append(nameDealer.lumidataTableName()) if not schema.existsTable(nameDealer.lumisummaryv2TableName()): print('creating lumisummaryv2 table') summary = coral.TableDescription() summary.setName(nameDealer.lumisummaryv2TableName()) summary.insertColumn('DATA_ID', 'unsigned long long') summary.insertColumn('RUNNUM', 'unsigned int') summary.insertColumn('LUMILSNUM', 'unsigned int') summary.insertColumn('CMSLSNUM', 'unsigned int') summary.insertColumn('INSTLUMI', 'float') summary.insertColumn('INSTLUMIERROR', 'float') summary.insertColumn('INSTLUMIQUALITY', 'short') summary.insertColumn('BEAMSTATUS', 'string', 28, False) summary.insertColumn('BEAMENERGY', 'float') summary.insertColumn('NUMORBIT', 'unsigned int') summary.insertColumn('STARTORBIT', 'unsigned int') summary.insertColumn('CMSBXINDEXBLOB', 'blob') summary.insertColumn('BEAMINTENSITYBLOB_1', 'blob') summary.insertColumn('BEAMINTENSITYBLOB_2', 'blob') summary.insertColumn('BXLUMIVALUE_OCC1', 'blob') summary.insertColumn('BXLUMIVALUE_OCC2', 'blob') summary.insertColumn('BXLUMIVALUE_ET', 'blob') summary.insertColumn('BXLUMIERROR_OCC1', 'blob') summary.insertColumn('BXLUMIERROR_OCC2', 'blob') summary.insertColumn('BXLUMIERROR_ET', 'blob') summary.insertColumn('BXLUMIQUALITY_OCC1', 'blob') summary.insertColumn('BXLUMIQUALITY_OCC2', 'blob') summary.insertColumn('BXLUMIQUALITY_ET', 'blob') summary.setPrimaryKey(('DATA_ID', 'LUMILSNUM')) db.createTable(summary, withIdTable=False) created.append(nameDealer.lumisummaryv2TableName()) # # This table exists in the old schema # if not schema.existsTable(nameDealer.cmsrunsummaryTableName()): print('creating cmsrunsummary table') cmsrunsummary = coral.TableDescription() cmsrunsummary.setName(nameDealer.cmsrunsummaryTableName()) cmsrunsummary.insertColumn('RUNNUM', 'unsigned int') cmsrunsummary.insertColumn('HLTKEY', 'string', 128, False) cmsrunsummary.insertColumn('L1KEY', 'string', 128, False) cmsrunsummary.insertColumn('FILLNUM', 'unsigned int') cmsrunsummary.insertColumn('SEQUENCE', 'string', 56, False) cmsrunsummary.insertColumn('STARTTIME', 'time stamp', 6) cmsrunsummary.insertColumn('STOPTIME', 'time stamp', 6) cmsrunsummary.insertColumn('EGEV', 'unsigned int') cmsrunsummary.insertColumn('AMODETAG', 'string', 28, False) cmsrunsummary.insertColumn('FILLSCHEME', 'string', 128, False) cmsrunsummary.insertColumn('NCOLLIDINGBUNCHES', 'usigned int') cmsrunsummary.setPrimaryKey('RUNNUM') db.createTable(cmsrunsummary, withIdTable=False) created.append(nameDealer.cmsrunsummaryTableName()) # # This table exists in the old schema # if not schema.existsTable(nameDealer.trghltMapTableName()): print('creating trghltmap table') trghlt = coral.TableDescription() trghlt.setName(nameDealer.trghltMapTableName()) trghlt.insertColumn('HLTKEY', 'string', 128, False) trghlt.insertColumn('HLTPATHNAME', 'string', 256, False) trghlt.insertColumn('L1SEED', 'string', 1024, False) trghlt.setNotNullConstraint('HLTKEY', True) trghlt.setNotNullConstraint('HLTPATHNAME', True) trghlt.setNotNullConstraint('L1SEED', True) db.createTable(trghlt, withIdTable=False) created.append(nameDealer.trghltMapTableName()) if not schema.existsTable(nameDealer.trgdataTableName()): print('creating trgdata table') trgdataTab = coral.TableDescription() trgdataTab.setName(nameDealer.trgdataTableName()) trgdataTab.insertColumn('DATA_ID', 'unsigned long long') trgdataTab.insertColumn('ENTRY_ID', 'unsigned long long') trgdataTab.insertColumn('ENTRY_NAME', 'string', 56, False) trgdataTab.insertColumn('SOURCE', 'string', 128, False) trgdataTab.insertColumn('RUNNUM', 'unsigned int') trgdataTab.insertColumn('BITZERONAME', 'string', 56, False) trgdataTab.insertColumn('BITNAMECLOB', 'string', 6000) trgdataTab.setPrimaryKey('DATA_ID') db.createTable(trgdataTab, withIdTable=True, withEntryTables=True, withRevMapTable=True) created.append(nameDealer.trgdataTableName()) if not schema.existsTable(nameDealer.lstrgTableName()): print('creating lstrg table') lstrgTab = coral.TableDescription() lstrgTab.setName(nameDealer.lstrgTableName()) lstrgTab.insertColumn('DATA_ID', 'unsigned long long') lstrgTab.insertColumn('RUNNUM', 'unsigned int') lstrgTab.insertColumn('CMSLSNUM', 'unsigned int') lstrgTab.insertColumn('DEADTIMECOUNT', 'unsigned long long') lstrgTab.insertColumn('BITZEROCOUNT', 'unsigned int') lstrgTab.insertColumn('BITZEROPRESCALE', 'unsigned int') lstrgTab.insertColumn('DEADFRAC', 'float') lstrgTab.insertColumn('PRESCALEBLOB', 'blob') lstrgTab.insertColumn('TRGCOUNTBLOB', 'blob') lstrgTab.setPrimaryKey(('DATA_ID', 'CMSLSNUM')) db.createTable(lstrgTab, withIdTable=False) created.append(nameDealer.lstrgTableName()) if not schema.existsTable(nameDealer.hltdataTableName()): print('creating hltdata table') hltdataTab = coral.TableDescription() hltdataTab.setName(nameDealer.hltdataTableName()) hltdataTab.insertColumn('DATA_ID', 'unsigned long long') hltdataTab.insertColumn('ENTRY_ID', 'unsigned long long') hltdataTab.insertColumn('ENTRY_NAME', 'string', 56, False) hltdataTab.insertColumn('RUNNUM', 'unsigned int') hltdataTab.insertColumn('SOURCE', 'string', 128, False) hltdataTab.insertColumn('NPATH', 'unsigned int') hltdataTab.insertColumn('PATHNAMECLOB', 'string', 6000) hltdataTab.setPrimaryKey('DATA_ID') db.createTable(hltdataTab, withIdTable=True, withEntryTables=True, withRevMapTable=True) created.append(nameDealer.hltTableName()) if not schema.existsTable(nameDealer.lshltTableName()): print('creating lshlt table') lshltTab = coral.TableDescription() lshltTab.setName(nameDealer.lshltTableName()) lshltTab.insertColumn('DATA_ID', 'unsigned long long') lshltTab.insertColumn('RUNNUM', 'unsigned int') lshltTab.insertColumn('CMSLSNUM', 'unsigned int') lshltTab.insertColumn('PRESCALEBLOB', 'blob') lshltTab.insertColumn('HLTCOUNTBLOB', 'blob') lshltTab.insertColumn('HLTACCEPTBLOB', 'blob') db.createTable(lshltTab, withIdTable=False) lshltTab.setPrimaryKey(('DATA_ID', 'CMSLSNUM')) created.append(nameDealer.lshltTableName()) if not schema.existsTable(nameDealer.lumivalidationTableName()): print('creating lumivalidation table') lumivalidation = coral.TableDescription() lumivalidation.setName(nameDealer.lumivalidationTableName()) lumivalidation.insertColumn('RUNNUM', 'unsigned int') lumivalidation.insertColumn('CMSLSNUM', 'unsigned int') lumivalidation.insertColumn('FLAG', 'string', 28, False) lumivalidation.insertColumn('COMMENT', 'string', 1024, False) lumivalidation.setPrimaryKey(('RUNNUM', 'CMSLSNUM')) lumivalidation.setNotNullConstraint('FLAG', True) db.createTable(lumivalidation, withIdTable=False) created.append(nameDealer.lumivalidationTableName()) return created except: raise