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, authFile=None)
 
def check_table (self, table_def, table_class)
 
def connect (self, url=None)
 
def get_url (self, force_schema=False)
 

Public Attributes

 authFile
 
 db_service
 
 engine
 
 schema
 
 session
 

Detailed Description

Definition at line 30 of file o2o_db_manager.py.

Constructor & Destructor Documentation

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

Definition at line 31 of file o2o_db_manager.py.

31  def __init__(self, db, authFile=None):
32  self.authFile = authFile
33  if db == 'prod':
34  self.db_service = prod_db_service
35  elif db == 'dev':
36  self.db_service = dev_db_service
37  elif db == 'private':
38  self.db_service = None
39  else:
40  raise RuntimeError('Option db(=%s) is not in the supported database list: [prod, dev, private]' % db)
41 
42  logging.info('Connecting to %s database' % self.db_service[0] if self.db_service else private_db)
43 
44  self.schema = schema_dict[self.db_service[0]] if self.db_service else None
45 
def __init__(self, db, authFile=None)

Member Function Documentation

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

Definition at line 57 of file o2o_db_manager.py.

Referenced by o2o_db_cfgmap.DbManagerDAQ.update_hashmap().

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

Definition at line 66 of file o2o_db_manager.py.

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

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea.__init__(), Vispa.Views.PropertyView.BooleanProperty.__init__(), Vispa.Gui.FindDialog.FindDialog._addScript(), Vispa.Gui.FindDialog.FindDialog._addStringProperty(), Vispa.Main.Application.Application._connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView._createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog.addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer.addWidget(), Vispa.Views.PropertyView.PropertyView.append(), Vispa.Views.PropertyView.PropertyView.appendAddRow(), Vispa.Main.Application.Application.createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty.createButton(), Vispa.Views.LineDecayView.LineDecayView.createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty.createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer.createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty.createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.find(), Vispa.Gui.PortWidget.PortWidget.mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty.setChecked(), Vispa.Main.SplitterTab.SplitterTab.setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab.setController(), Vispa.Views.PropertyView.BooleanProperty.setReadOnly(), Vispa.Views.PropertyView.DropDownProperty.setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty.setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.setTab(), Vispa.Views.PropertyView.IntegerProperty.setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.switchCenterView(), o2o_db_cfgmap.DbManagerDAQ.update_hashmap(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController.updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.updateViewMenu().

66  def connect(self, url=None):
67  engine = sqlalchemy.create_engine(url) if url else self.engine
68  session = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker(bind=engine))
69  return session
70 
def o2o_db_manager.DbManager.get_url (   self,
  force_schema = False 
)

Definition at line 46 of file o2o_db_manager.py.

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

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

Member Data Documentation

o2o_db_manager.DbManager.authFile

Definition at line 32 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.get_url().

o2o_db_manager.DbManager.db_service

Definition at line 34 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.get_url().

o2o_db_manager.DbManager.engine

Definition at line 58 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.connect().

o2o_db_manager.DbManager.schema

Definition at line 44 of file o2o_db_manager.py.

Referenced by o2o_db_manager.DbManager.get_url().

o2o_db_manager.DbManager.session

Definition at line 64 of file o2o_db_manager.py.