CMS 3D CMS Logo

lumidbDDL.py
Go to the documentation of this file.
1 import coral
2 from RecoLuminosity.LumiDB import nameDealer,dbUtil
3 #=======================================================
4 #
5 # CREATE
6 #
7 #=======================================================
8 def createTables(schema):
9  '''
10  create new tables if not exist
11  revisions,revisions_id,luminorms,luminorms_entries,luminorms_entries_id,fillscheme
12  '''
13  try:
14  created=[]
15  db=dbUtil.dbUtil(schema)
16  if not schema.existsTable(nameDealer.fillschemeTableName()):
17  print 'creating fillscheme table'
18  fillschemeTab=coral.TableDescription()
19  fillschemeTab.setName( nameDealer.fillschemeTableName() )
20  fillschemeTab.insertColumn( 'FILLSCHEME_ID','unsigned long long' )
21  fillschemeTab.insertColumn( 'FILLSCHEMEPATTERN','string',128,False )
22  fillschemeTab.insertColumn( 'CORRECTIONFACTOR','float' )
23  fillschemeTab.setPrimaryKey( 'FILLSCHEME_ID' )
24  db.createTable(fillschemeTab,withIdTable=True)
25  created.append( nameDealer.fillschemeTableName() )
26 
27  if not schema.existsTable(nameDealer.revisionTableName()):
28  print 'creating revisions table'
29  revisionsTab=coral.TableDescription()
30  revisionsTab.setName( nameDealer.revisionTableName() )
31  revisionsTab.insertColumn( 'REVISION_ID','unsigned long long')
32  revisionsTab.insertColumn( 'BRANCH_ID','unsigned long long')
33  revisionsTab.insertColumn( 'NAME', 'string',56,False)
34  revisionsTab.insertColumn( 'BRANCH_NAME', 'string',56,False)
35  revisionsTab.insertColumn( 'COMMENT', 'string',1024,False)
36  revisionsTab.insertColumn( 'CTIME', 'time stamp',6)
37  revisionsTab.setPrimaryKey( 'REVISION_ID' )
38  revisionsTab.setUniqueConstraint(('NAME'))
39  db.createTable(revisionsTab,withIdTable=True)
40  created.append(nameDealer.revisionTableName())
41 
42  if not schema.existsTable(nameDealer.luminormTableName()):
43  print 'creating luminorms table'
44  luminormsTab=coral.TableDescription()
45  luminormsTab.setName( nameDealer.luminormTableName() )
46  luminormsTab.insertColumn( 'DATA_ID','unsigned long long')
47  luminormsTab.insertColumn( 'ENTRY_ID','unsigned long long')
48  luminormsTab.insertColumn( 'ENTRY_NAME','string',56,False)
49  luminormsTab.insertColumn( 'AMODETAG', 'string',28,False)
50  luminormsTab.insertColumn( 'NORM_1', 'float')
51  luminormsTab.insertColumn( 'EGEV_1', 'unsigned int')
52  luminormsTab.insertColumn( 'NORM_2', 'float')
53  luminormsTab.insertColumn( 'EGEV_2', 'unsigned int')
54  luminormsTab.setPrimaryKey( 'DATA_ID' )
55  db.createTable(luminormsTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
56  created.append(nameDealer.luminormTableName())
57 
58  if not schema.existsTable(nameDealer.lumidataTableName()):
59  print 'creating lumidata table'
60  lumidataTab=coral.TableDescription()
61  lumidataTab.setName( nameDealer.lumidataTableName() )
62  lumidataTab.insertColumn( 'DATA_ID','unsigned long long')
63  lumidataTab.insertColumn( 'ENTRY_ID','unsigned long long')
64  lumidataTab.insertColumn( 'ENTRY_NAME','string',56,False)
65  lumidataTab.insertColumn( 'SOURCE', 'string',128,False)
66  lumidataTab.insertColumn( 'RUNNUM', 'unsigned int')
67  lumidataTab.insertColumn( 'NOMINALEGEV', 'float')
68  lumidataTab.setPrimaryKey( 'DATA_ID' )
69  db.createTable(lumidataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
70  created.append(nameDealer.lumidataTableName())
71 
72  if not schema.existsTable(nameDealer.lumisummaryv2TableName() ):
73  print 'creating lumisummaryv2 table'
74  summary=coral.TableDescription()
75  summary.setName( nameDealer.lumisummaryv2TableName() )
76  summary.insertColumn('DATA_ID','unsigned long long')
77  summary.insertColumn('RUNNUM','unsigned int')
78  summary.insertColumn('LUMILSNUM','unsigned int')
79  summary.insertColumn('CMSLSNUM','unsigned int')
80  summary.insertColumn('INSTLUMI','float')
81  summary.insertColumn('INSTLUMIERROR','float')
82  summary.insertColumn('INSTLUMIQUALITY','short')
83  summary.insertColumn('BEAMSTATUS','string',28,False)
84  summary.insertColumn('BEAMENERGY','float')
85  summary.insertColumn('NUMORBIT','unsigned int')
86  summary.insertColumn('STARTORBIT','unsigned int')
87  summary.insertColumn('CMSBXINDEXBLOB','blob')
88  summary.insertColumn('BEAMINTENSITYBLOB_1','blob')
89  summary.insertColumn('BEAMINTENSITYBLOB_2','blob')
90  summary.insertColumn('BXLUMIVALUE_OCC1','blob')
91  summary.insertColumn('BXLUMIVALUE_OCC2','blob')
92  summary.insertColumn('BXLUMIVALUE_ET','blob')
93  summary.insertColumn('BXLUMIERROR_OCC1','blob')
94  summary.insertColumn('BXLUMIERROR_OCC2','blob')
95  summary.insertColumn('BXLUMIERROR_ET','blob')
96  summary.insertColumn('BXLUMIQUALITY_OCC1','blob')
97  summary.insertColumn('BXLUMIQUALITY_OCC2','blob')
98  summary.insertColumn('BXLUMIQUALITY_ET','blob')
99  summary.setPrimaryKey(('DATA_ID','LUMILSNUM'))
100  db.createTable(summary,withIdTable=False)
101  created.append(nameDealer.lumisummaryv2TableName())
102 
103  #
104  # This table exists in the old schema
105  #
106  if not schema.existsTable(nameDealer.cmsrunsummaryTableName()):
107  print 'creating cmsrunsummary table'
108  cmsrunsummary=coral.TableDescription()
109  cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() )
110  cmsrunsummary.insertColumn('RUNNUM','unsigned int')
111  cmsrunsummary.insertColumn('HLTKEY','string',128,False)
112  cmsrunsummary.insertColumn('L1KEY','string',128,False)
113  cmsrunsummary.insertColumn('FILLNUM','unsigned int')
114  cmsrunsummary.insertColumn('SEQUENCE','string',56,False)
115  cmsrunsummary.insertColumn('STARTTIME','time stamp',6)
116  cmsrunsummary.insertColumn('STOPTIME','time stamp',6)
117  cmsrunsummary.insertColumn('EGEV','unsigned int')
118  cmsrunsummary.insertColumn('AMODETAG','string',28,False)
119  cmsrunsummary.insertColumn('FILLSCHEME','string',128,False)
120  cmsrunsummary.insertColumn('NCOLLIDINGBUNCHES','usigned int')
121  cmsrunsummary.setPrimaryKey('RUNNUM')
122  db.createTable(cmsrunsummary,withIdTable=False)
123  created.append(nameDealer.cmsrunsummaryTableName())
124  #
125  # This table exists in the old schema
126  #
127  if not schema.existsTable(nameDealer.trghltMapTableName()):
128  print 'creating trghltmap table'
129  trghlt=coral.TableDescription()
130  trghlt.setName( nameDealer.trghltMapTableName() )
131  trghlt.insertColumn( 'HLTKEY','string',128,False )
132  trghlt.insertColumn( 'HLTPATHNAME','string',256,False )
133  trghlt.insertColumn( 'L1SEED','string' ,1024,False)
134  trghlt.setNotNullConstraint('HLTKEY',True)
135  trghlt.setNotNullConstraint('HLTPATHNAME',True)
136  trghlt.setNotNullConstraint('L1SEED',True)
137  db.createTable(trghlt,withIdTable=False)
138  created.append(nameDealer.trghltMapTableName())
139  if not schema.existsTable(nameDealer.trgdataTableName()):
140  print 'creating trgdata table'
141  trgdataTab=coral.TableDescription()
142  trgdataTab.setName( nameDealer.trgdataTableName() )
143  trgdataTab.insertColumn( 'DATA_ID','unsigned long long')
144  trgdataTab.insertColumn( 'ENTRY_ID','unsigned long long')
145  trgdataTab.insertColumn( 'ENTRY_NAME','string',56,False)
146  trgdataTab.insertColumn( 'SOURCE', 'string',128,False)
147  trgdataTab.insertColumn( 'RUNNUM', 'unsigned int')
148  trgdataTab.insertColumn( 'BITZERONAME', 'string',56,False)
149  trgdataTab.insertColumn( 'BITNAMECLOB', 'string',6000)
150  trgdataTab.setPrimaryKey( 'DATA_ID' )
151  db.createTable(trgdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
152  created.append(nameDealer.trgdataTableName())
153  if not schema.existsTable(nameDealer.lstrgTableName()):
154  print 'creating lstrg table'
155  lstrgTab=coral.TableDescription()
156  lstrgTab.setName( nameDealer.lstrgTableName() )
157  lstrgTab.insertColumn( 'DATA_ID','unsigned long long')
158  lstrgTab.insertColumn( 'RUNNUM', 'unsigned int')
159  lstrgTab.insertColumn( 'CMSLSNUM', 'unsigned int')
160  lstrgTab.insertColumn( 'DEADTIMECOUNT', 'unsigned long long')
161  lstrgTab.insertColumn( 'BITZEROCOUNT', 'unsigned int')
162  lstrgTab.insertColumn( 'BITZEROPRESCALE', 'unsigned int')
163  lstrgTab.insertColumn( 'DEADFRAC', 'float')
164  lstrgTab.insertColumn( 'PRESCALEBLOB', 'blob')
165  lstrgTab.insertColumn( 'TRGCOUNTBLOB', 'blob')
166  lstrgTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') )
167  db.createTable(lstrgTab,withIdTable=False)
168  created.append( nameDealer.lstrgTableName() )
169 
170  if not schema.existsTable(nameDealer.hltdataTableName()):
171  print 'creating hltdata table'
172  hltdataTab=coral.TableDescription()
173  hltdataTab.setName( nameDealer.hltdataTableName() )
174  hltdataTab.insertColumn( 'DATA_ID','unsigned long long')
175  hltdataTab.insertColumn( 'ENTRY_ID','unsigned long long')
176  hltdataTab.insertColumn( 'ENTRY_NAME','string',56,False)
177  hltdataTab.insertColumn( 'RUNNUM', 'unsigned int')
178  hltdataTab.insertColumn( 'SOURCE', 'string',128,False)
179  hltdataTab.insertColumn( 'NPATH', 'unsigned int')
180  hltdataTab.insertColumn( 'PATHNAMECLOB', 'string',6000)
181  hltdataTab.setPrimaryKey( 'DATA_ID' )
182  db.createTable(hltdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
183  created.append(nameDealer.hltTableName())
184 
185  if not schema.existsTable(nameDealer.lshltTableName()):
186  print 'creating lshlt table'
187  lshltTab=coral.TableDescription()
188  lshltTab.setName( nameDealer.lshltTableName() )
189  lshltTab.insertColumn( 'DATA_ID','unsigned long long')
190  lshltTab.insertColumn( 'RUNNUM', 'unsigned int')
191  lshltTab.insertColumn( 'CMSLSNUM', 'unsigned int')
192  lshltTab.insertColumn( 'PRESCALEBLOB', 'blob')
193  lshltTab.insertColumn( 'HLTCOUNTBLOB', 'blob')
194  lshltTab.insertColumn( 'HLTACCEPTBLOB', 'blob')
195  db.createTable(lshltTab,withIdTable=False)
196  lshltTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') )
197  created.append(nameDealer.lshltTableName())
198 
199 
200  if not schema.existsTable(nameDealer.lumivalidationTableName()):
201  print 'creating lumivalidation table'
202  lumivalidation=coral.TableDescription()
203  lumivalidation.setName( nameDealer.lumivalidationTableName() )
204  lumivalidation.insertColumn( 'RUNNUM','unsigned int' )
205  lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' )
206  lumivalidation.insertColumn( 'FLAG','string',28,False )
207  lumivalidation.insertColumn( 'COMMENT','string',1024,False )
208  lumivalidation.setPrimaryKey( ('RUNNUM','CMSLSNUM') )
209  lumivalidation.setNotNullConstraint('FLAG',True)
210  db.createTable(lumivalidation,withIdTable=False)
211  created.append(nameDealer.lumivalidationTableName())
212  return created
213  except :
214  raise
215 
216 
217 #=======================================================
218 #
219 # DROP
220 #
221 #=======================================================
222 def dropTables(schema,tablelist):
223  try:
224  db=dbUtil.dbUtil(schema)
225  for tablename in tablelist:
227  db.dropTable( nameDealer.idTableName(tablename) )
228  db.dropTable( nameDealer.entryTableName(tablename) )
229  db.dropTable( nameDealer.revmapTableName(tablename) )
231  db.dropTable( nameDealer.idTableName(tablename) )
232  db.dropTable( tablename )
233  except :
234  raise
235 
236 def createOldSchema(schema):
237  '''
238  create tables of lumidb1 if not exist
239  '''
240  try:
241  created=[]
242  db=dbUtil.dbUtil(schema)
243  if not schema.existsTable(nameDealer.lumivalidationTableName()):
244  lumivalidation=coral.TableDescription()
245  lumivalidation.setName( nameDealer.lumivalidationTableName() )
246  lumivalidation.insertColumn( 'RUNNUM','unsigned int' )
247  lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' )
248  lumivalidation.insertColumn( 'FLAG','string',28,False )
249  lumivalidation.insertColumn( 'COMMENT','string',1024,False )
250  lumivalidation.setPrimaryKey(('RUNNUM','CMSLSNUM'))
251  lumivalidation.setNotNullConstraint('FLAG',True)
252  db.createTable(lumivalidation,withIdTable=False)
253  created.append(nameDealer.lumivalidationTableName())
254 
255  if not schema.existsTable(nameDealer.cmsrunsummaryTableName()):
256  cmsrunsummary=coral.TableDescription()
257  cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() )
258  cmsrunsummary.insertColumn('RUNNUM','unsigned int')
259  cmsrunsummary.insertColumn('HLTKEY','string',128,False)
260  cmsrunsummary.insertColumn('FILLNUM','unsigned int')
261  cmsrunsummary.insertColumn('SEQUENCE','string',56,False)
262  cmsrunsummary.insertColumn('STARTTIME','time stamp',6)
263  cmsrunsummary.insertColumn('STOPTIME','time stamp',6)
264  cmsrunsummary.setPrimaryKey('RUNNUM')
265  cmsrunsummary.setNotNullConstraint('HLTKEY',True)
266  cmsrunsummary.setNotNullConstraint('FILLNUM',True)
267  cmsrunsummary.setNotNullConstraint('SEQUENCE',True)
268  cmsrunsummary.createIndex('cmsrunsummary_fillnum',('FILLNUM'))
269  cmsrunsummary.createIndex('cmsrunsummary_startime',('STARTTIME'))
270  db.createTable(cmsrunsummary,withIdTable=False)
271  created.append(nameDealer.cmsrunsummaryTableName())
272 
273  if not schema.existsTable(nameDealer.lumisummaryTableName()):
274  summary=coral.TableDescription()
275  summary.setName( nameDealer.lumisummaryTableName() )
276  summary.insertColumn('LUMISUMMARY_ID','unsigned long long')
277  summary.insertColumn('RUNNUM','unsigned int')
278  summary.insertColumn('CMSLSNUM','unsigned int')
279  summary.insertColumn('LUMILSNUM','unsigned int')
280  summary.insertColumn('LUMIVERSION','string',28,False)
281  summary.insertColumn('DTNORM','float')
282  summary.insertColumn('LHCNORM','float')
283  summary.insertColumn('CMSALIVE','short')
284  summary.insertColumn('INSTLUMI','float')
285  summary.insertColumn('INSTLUMIERROR','float')
286  summary.insertColumn('INSTLUMIQUALITY','short')
287  summary.insertColumn('BEAMSTATUS','string',28,False)
288  summary.insertColumn('BEAMENERGY','float')
289  summary.insertColumn('NUMORBIT','unsigned int')
290  summary.insertColumn('STARTORBIT','unsigned int')
291  summary.insertColumn('LUMISECTIONQUALITY','short')
292  summary.insertColumn('CMSBXINDEXBLOB','blob')
293  summary.insertColumn('BEAMINTENSITYBLOB_1','blob')
294  summary.insertColumn('BEAMINTENSITYBLOB_2','blob')
295  summary.setPrimaryKey('LUMISUMMARY_ID')
296  summary.setNotNullConstraint('RUNNUM',True)
297  summary.setNotNullConstraint('CMSLSNUM',True)
298  summary.setNotNullConstraint('LUMILSNUM',True)
299  summary.setNotNullConstraint('CMSALIVE',True)
300  summary.setNotNullConstraint('LUMIVERSION',True)
301  summary.setNotNullConstraint('DTNORM',True)
302  summary.setNotNullConstraint('LHCNORM',True)
303  summary.setNotNullConstraint('INSTLUMI',True)
304  summary.setNotNullConstraint('INSTLUMIERROR',True)
305  summary.setNotNullConstraint('INSTLUMIQUALITY',True)
306  summary.setNotNullConstraint('STARTORBIT',True)
307  summary.setNotNullConstraint('NUMORBIT',True)
308  summary.setNotNullConstraint('LUMISECTIONQUALITY',True)
309  summary.setNotNullConstraint('BEAMENERGY',True)
310  summary.setNotNullConstraint('BEAMSTATUS',True)
311  summary.setUniqueConstraint(('RUNNUM','LUMIVERSION','LUMILSNUM'))
312  summary.createIndex('lumisummary_runnum',('RUNNUM'))
313  db.createTable(summary,withIdTable=True)
314  created.append(nameDealer.lumisummaryTableName())
315 
316  if not schema.existsTable(nameDealer.lumidetailTableName()):
317  detail=coral.TableDescription()
318  detail.setName( nameDealer.lumidetailTableName() )
319  detail.insertColumn('LUMIDETAIL_ID','unsigned long long')
320  detail.insertColumn('LUMISUMMARY_ID','unsigned long long')
321  detail.insertColumn('BXLUMIVALUE','blob')
322  detail.insertColumn('BXLUMIERROR','blob')
323  detail.insertColumn('BXLUMIQUALITY','blob')
324  detail.insertColumn('ALGONAME','string',28,False)
325  detail.setPrimaryKey('LUMIDETAIL_ID')
326  detail.createForeignKey('DETAILSOURCE','LUMISUMMARY_ID',nameDealer.lumisummaryTableName(),'LUMISUMMARY_ID')
327  detail.setNotNullConstraint('BXLUMIVALUE',True)
328  detail.setNotNullConstraint('BXLUMIERROR',True)
329  detail.setNotNullConstraint('BXLUMIQUALITY',True)
330  detail.setNotNullConstraint('ALGONAME',True)
331  detail.setUniqueConstraint(('LUMISUMMARY_ID','ALGONAME'))
332  db.createTable(detail,withIdTable=True)
333  created.append(nameDealer.lumidetailTableName())
334 
335  if not schema.existsTable(nameDealer.trgTableName()):
336  trg=coral.TableDescription()
337  trg.setName( nameDealer.trgTableName() )
338  trg.insertColumn('TRG_ID','unsigned long long')
339  trg.insertColumn('RUNNUM','unsigned int')
340  trg.insertColumn('CMSLSNUM','unsigned int')
341  trg.insertColumn('BITNUM','unsigned int')
342  trg.insertColumn('BITNAME','string',56,False)
343  trg.insertColumn('TRGCOUNT','unsigned int')
344  trg.insertColumn('DEADTIME','unsigned long long')
345  trg.insertColumn('PRESCALE','unsigned int')
346  trg.setNotNullConstraint('RUNNUM',True)
347  trg.setNotNullConstraint('CMSLSNUM',True)
348  trg.setNotNullConstraint('BITNUM',True)
349  trg.setNotNullConstraint('BITNAME',True)
350  trg.setNotNullConstraint('TRGCOUNT',True)
351  trg.setNotNullConstraint('DEADTIME',True)
352  trg.setNotNullConstraint('PRESCALE',True)
353  trg.setPrimaryKey('TRG_ID')
354  trg.createIndex('trg_runnum',('RUNNUM'))
355  db.createTable(trg,withIdTable=True)
356  created.append( nameDealer.trgTableName() )
357 
358  if not schema.existsTable( nameDealer.hltTableName() ):
359  hlt=coral.TableDescription()
360  hlt.setName( nameDealer.hltTableName() )
361  hlt.insertColumn( 'HLT_ID','unsigned long long')
362  hlt.insertColumn( 'RUNNUM','unsigned int')
363  hlt.insertColumn( 'CMSLSNUM','unsigned int')
364  hlt.insertColumn( 'PATHNAME','string',256,False)
365  hlt.insertColumn( 'INPUTCOUNT','unsigned int')
366  hlt.insertColumn( 'ACCEPTCOUNT','unsigned int')
367  hlt.insertColumn( 'PRESCALE','unsigned int')
368  hlt.setPrimaryKey( 'HLT_ID' )
369  hlt.setNotNullConstraint('RUNNUM',True)
370  hlt.setNotNullConstraint('CMSLSNUM',True)
371  hlt.setNotNullConstraint('PATHNAME',True)
372  hlt.setNotNullConstraint('INPUTCOUNT',True)
373  hlt.setNotNullConstraint('ACCEPTCOUNT',True)
374  hlt.setNotNullConstraint('PRESCALE',True)
375  hlt.createIndex('hlt_runnum',('RUNNUM'))
376  db.createTable(hlt,withIdTable=True)
377  created.append( nameDealer.hltTableName() )
378 
379  if not schema.existsTable( nameDealer.trghltMapTableName() ):
380  trghlt=coral.TableDescription()
381  trghlt.setName( nameDealer.trghltMapTableName() )
382  trghlt.insertColumn( 'HLTKEY','string',128,False )
383  trghlt.insertColumn( 'HLTPATHNAME','string',256,False )
384  trghlt.insertColumn( 'L1SEED','string',1024,false )
385  trghlt.setNotNullConstraint('HLTKEY',True)
386  trghlt.setNotNullConstraint('HLTPATHNAME',True)
387  trghlt.setNotNullConstraint('L1SEED',True)
388  db.createTable(trghlt,withIdTable=False)
389  created.append( nameDealer.trghltMapTableName() )
390  return created
391  except:
392  raise
393 
394 #=======================================================
395 #
396 # MODIFY
397 #
398 #=======================================================
399 def oldToNew(schema):
400  '''
401  modify old tables:cmsrunsummary
402  alter table cmsrunsummary add column(l1key string,egev unsigned int,amodetag string)
403  '''
404  try:
405  tableHandle=schema.tableHandle(nameDealer.cmsrunsummaryTableName())
406  tableHandle.schemaEditor().insertColumn('L1KEY','string',128,False)
407  tableHandle.schemaEditor().insertColumn('EGEV','unsigned int')
408  tableHandle.schemaEditor().insertColumn('AMODETAG','string',28,False)
409  createTables(schema)
410  except:
411  raise
412 
413 def newToOld(schema):
414  try:
415  dropTables(schema,['REVISIONS','LUMINORMS','LUMIDATA','LUMISUMMARYV2','TRGDATA','LSTRG','HLTDATA','LSHLT'])
416  tableHandle=schema.tableHandle(nameDealer.cmsrunsummaryTableName())
417  ncol=tableHandle.description().numberOfColumns()
418  todrop=[]
419  for i in range(ncol):
420  colname=tableHandle.description().columnDescription(i).name()
421  if colname in ['L1KEY','EGEV','AMODETAG']:
422  todrop.append(colname)
423  for colname in todrop:
424  tableHandle.schemaEditor().dropColumn(colname)
425  except :
426  raise
427 
428 #=======================================================
429 #
430 # TODO
431 #
432 #=======================================================
433 
434 def createIndices(schema):
435  '''
436  '''
437  pass
438  #cmsrunsummary.createIndex('cmsrunsummary_fillnum',('FILLNUM'))
439  #cmsrunsummary.createIndex('cmsrunsummary_startime',('STARTTIME'))
440 
441 def dropIndices(schema):
442  '''
443  '''
444  pass
445 def describeIndices(schema):
446  '''
447  '''
448  pass
450  '''
451  '''
452  pass
453 def dropFKConstrains(schema):
454  '''
455  '''
456  pass
458  '''
459  '''
460  #cmsrunsummary.setNotNullConstraint('HLTKEY',True)
461  #cmsrunsummary.setNotNullConstraint('FILLNUM',True)
462  #cmsrunsummary.setNotNullConstraint('SEQUENCE',True)
463  pass
465  '''
466  '''
467  pass
468 
470  '''
471  '''
472  try:
473  revtable=schema.tableHandle(nameDealer.revisionTableName())
474  revtable.schemaEditor().setUniqueConstraint('NAME','revisions_name_uc')
475  except:
476  raise
478  '''
479  '''
480  pass
481 
482 def describe(schema):
483  '''
484  '''
485  pass
486 
487 if __name__ == "__main__":
488  import sessionManager
489  myconstr='oracle://devdb10/cms_xiezhen_dev'
490  authpath='/afs/cern.ch/user/x/xiezhen'
491  #myconstr='sqlite_file:test.db'
492  svc=sessionManager.sessionManager(myconstr,authpath=authpath,debugON=False)
493  session=svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
494  schema=session.nominalSchema()
495  session.transaction().start(False)
496  tables=createTables(schema)
497  if len(tables)==0:
499  else:
500  dropTables(schema,tables)
502  #createUniqueConstraints(schema)
503  #session.transaction().commit()
504 
505  #print 'droped new '
506 
507  session.transaction().start(False)
508  tables=createOldSchema(schema)
509  oldToNew(schema)
510  print 'created old ',tables
511  session.transaction().commit()
512  del session
Definition: start.py:1
def dropTables(schema, tablelist)
Definition: lumidbDDL.py:222
def createTables(schema)
Definition: lumidbDDL.py:8
def dropIndices(schema)
Definition: lumidbDDL.py:441
def lumisummaryv2TableName()
Definition: nameDealer.py:28
def createOldSchema(schema)
Definition: lumidbDDL.py:236
def lumidetailTableName()
Definition: nameDealer.py:34
def trgTableName()
Definition: nameDealer.py:52
def commonTables()
Definition: nameDealer.py:9
def lumisummaryTableName()
Definition: nameDealer.py:25
def describeIndices(schema)
Definition: lumidbDDL.py:445
def createNULLConstraints(schema)
Definition: lumidbDDL.py:457
def entryTableName(dataTableName)
Definition: nameDealer.py:103
def luminormTableName()
Definition: nameDealer.py:37
def lumivalidationTableName()
Definition: nameDealer.py:85
def createIndices(schema)
Definition: lumidbDDL.py:434
def lshltTableName()
Definition: nameDealer.py:61
def oldToNew(schema)
Definition: lumidbDDL.py:399
def revisionTableName()
Definition: nameDealer.py:11
def createFKConstraints(schema)
Definition: lumidbDDL.py:449
def createUniqueConstraints(schema)
Definition: lumidbDDL.py:469
def revmapTableName(dataTableName)
Definition: nameDealer.py:100
def lstrgTableName()
Definition: nameDealer.py:49
def trgdataTableName()
Definition: nameDealer.py:46
def dropNULLConstraints(schema)
Definition: lumidbDDL.py:464
def hltTableName()
Definition: nameDealer.py:55
def fillschemeTableName()
Definition: nameDealer.py:13
def hltdataTableName()
Definition: nameDealer.py:58
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def idTableName(dataTableName)
Definition: nameDealer.py:94
def newToOld(schema)
Definition: lumidbDDL.py:413
def trghltMapTableName()
Definition: nameDealer.py:76
def dropUNIQUEConstraints(schema)
Definition: lumidbDDL.py:477
def dropFKConstrains(schema)
Definition: lumidbDDL.py:453
def lumidataTableName()
Definition: nameDealer.py:19
def describe(schema)
Definition: lumidbDDL.py:482
def schemaV2Tables()
Definition: nameDealer.py:5