CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
o2o_db_manager.DbManager Class Reference
Inheritance diagram for o2o_db_manager.DbManager:

Public Member Functions

def __init__ (self, db, authPath=None)
 
def check_table (self, table_def, table_class)
 
def connect (self, url=None)
 
def get_url (self, force_schema=False)
 

Public Attributes

 authPath
 
 db_service
 
 engine
 
 schema
 
 session
 

Detailed Description

Definition at line 29 of file o2o_db_manager.py.

Constructor & Destructor Documentation

◆ __init__()

def o2o_db_manager.DbManager.__init__ (   self,
  db,
  authPath = None 
)

Definition at line 30 of file o2o_db_manager.py.

30  def __init__(self, db, authPath=None):
31  self.authPath = authPath
32  if db == 'prod':
33  self.db_service = prod_db_service
34  elif db == 'dev':
35  self.db_service = dev_db_service
36  elif db == 'private':
37  self.db_service = None
38  else:
39  raise RuntimeError('Option db(=%s) is not in the supported database list: [prod, dev, private]' % db)
40 
41  logging.info('Connecting to %s database' % self.db_service[0] if self.db_service else private_db)
42 
43  self.schema = schema_dict[self.db_service[0]] if self.db_service else None
44 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ check_table()

def o2o_db_manager.DbManager.check_table (   self,
  table_def,
  table_class 
)

Definition at line 56 of file o2o_db_manager.py.

Referenced by o2o_db_cfgmap.DbManagerDAQ.update_hashmap().

56  def check_table(self, table_def, table_class):
57  self.engine = sqlalchemy.create_engine(self.get_url())
58  if not self.engine.has_table(table_def.__tablename__, self.schema):
59  logging.info('Creating table %s on %s' % (table_def.__tablename__,
60  self.db_service[0] if self.db_service else private_db))
61  self.engine = sqlalchemy.create_engine(self.get_url(True))
62  table_class.__table__.create(bind=self.engine)
63  self.session = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker(bind=self.engine))
64 

◆ connect()

def o2o_db_manager.DbManager.connect (   self,
  url = None 
)

Definition at line 65 of file o2o_db_manager.py.

References o2o_db_manager.DbManager.engine, querying.connection.engine, and conddblib.Connection.engine.

Referenced by o2o_db_cfgmap.DbManagerDAQ.update_hashmap().

65  def connect(self, url=None):
66  engine = sqlalchemy.create_engine(url) if url else self.engine
67  session = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker(bind=engine))
68  return session
69 

◆ get_url()

def o2o_db_manager.DbManager.get_url (   self,
  force_schema = False 
)

Definition at line 45 of file o2o_db_manager.py.

References o2o_db_manager.DbManager.authPath, o2o_db_manager.DbManager.db_service, o2o_db_manager.DbManager.schema, and querying.connection.schema.

45  def get_url(self, force_schema=False):
46  if self.db_service == None:
47  url = private_db
48  else:
49  authEntry = self.db_service[1]
50  if force_schema and self.schema:
51  authEntry = '%s/%s' % (self.db_service[0], self.schema)
52  username, _, pwd = auth.get_credentials( authEntry, self.authPath)
53  url = sqlalchemy_tpl % (username, pwd, self.db_service[0])
54  return url
55 

Member Data Documentation

◆ authPath

o2o_db_manager.DbManager.authPath

Definition at line 31 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.get_url().

◆ db_service

o2o_db_manager.DbManager.db_service

Definition at line 33 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.get_url().

◆ engine

o2o_db_manager.DbManager.engine

Definition at line 57 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.connect().

◆ schema

o2o_db_manager.DbManager.schema

Definition at line 43 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.get_url().

◆ session

o2o_db_manager.DbManager.session

Definition at line 63 of file o2o_db_manager.py.