本文整理匯總了Python中oslo_db.sqlalchemy.session.EngineFacade方法的典型用法代碼示例。如果您正苦於以下問題:Python session.EngineFacade方法的具體用法?Python session.EngineFacade怎麽用?Python session.EngineFacade使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oslo_db.sqlalchemy.session
的用法示例。
在下文中一共展示了session.EngineFacade方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_facade
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def _create_facade(conf_group):
# This fragment is copied from oslo.db
return db_session.EngineFacade(
sql_connection=conf_group.connection,
slave_connection=conf_group.slave_connection,
sqlite_fk=False,
autocommit=True,
expire_on_commit=False,
mysql_sql_mode=conf_group.mysql_sql_mode,
idle_timeout=conf_group.idle_timeout,
connection_debug=conf_group.connection_debug,
max_pool_size=conf_group.max_pool_size,
max_overflow=conf_group.max_overflow,
pool_timeout=conf_group.pool_timeout,
sqlite_synchronous=conf_group.sqlite_synchronous,
connection_trace=conf_group.connection_trace,
max_retries=conf_group.max_retries,
retry_interval=conf_group.retry_interval)
示例2: __init__
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def __init__(self, url):
options = dict(CONF.database.items())
# set retries to 0 , since reconnection is already implemented
# in storage.__init__.get_connection_from_config function
options['max_retries'] = 0
# add vitrage opts to database group
for opt in storage.OPTS:
options.pop(opt.name, None)
self._engine_facade = db_session.EngineFacade(self._dress_url(url),
**options)
self._active_actions = ActiveActionsConnection(self._engine_facade)
self._events = EventsConnection(self._engine_facade)
self._templates = TemplatesConnection(self._engine_facade)
self._graph_snapshots = GraphSnapshotsConnection(self._engine_facade)
self._webhooks = WebhooksConnection(
self._engine_facade)
self._alarms = AlarmsConnection(
self._engine_facade)
self._edges = EdgesConnection(
self._engine_facade)
self._changes = ChangesConnection(
self._engine_facade)
self._history_facade = HistoryFacadeConnection(
self._engine_facade, self._alarms, self._edges, self._changes)
示例3: test_slave_connection
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def test_slave_connection(self):
paths = self.create_tempfiles([('db.master', ''), ('db.slave', '')],
ext='')
master_path = 'sqlite:///' + paths[0]
slave_path = 'sqlite:///' + paths[1]
facade = session.EngineFacade(
sql_connection=master_path,
slave_connection=slave_path
)
master = facade.get_engine()
self.assertEqual(master_path, str(master.url))
slave = facade.get_engine(use_slave=True)
self.assertEqual(slave_path, str(slave.url))
master_session = facade.get_session()
self.assertEqual(master_path, str(master_session.bind.url))
slave_session = facade.get_session(use_slave=True)
self.assertEqual(slave_path, str(slave_session.bind.url))
示例4: __init__
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def __init__(self, conf, url):
# Set max_retries to 0, since oslo.db in certain cases may attempt
# to retry making the db connection retried max_retries ^ 2 times
# in failure case and db reconnection has already been implemented
# in storage.__init__.get_connection_from_config function
options = dict(conf.database.items())
options['max_retries'] = 0
# oslo.db doesn't support options defined by Aodh
for opt in storage.OPTS:
options.pop(opt.name, None)
self._engine_facade = db_session.EngineFacade(self.dress_url(url),
**options)
if osprofiler_sqlalchemy:
osprofiler_sqlalchemy.add_tracing(sqlalchemy,
self._engine_facade.get_engine(),
'db')
self.conf = conf
示例5: _create_facade_lazily
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def _create_facade_lazily(cfg_group, connection=None, discriminator=None):
connection = connection or cfg.CONF[cfg_group].connection
cache_name = "%s:%s" % (cfg_group, discriminator)
if cache_name not in _FACADES:
conf = dict(cfg.CONF[cfg_group].items())
_FACADES[cache_name] = session.EngineFacade(
connection,
**conf
)
return _FACADES[cache_name]
示例6: get_facade
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def get_facade():
global _facade
if not _facade:
# TODO: investigate why the CONF.database.connection is None!
# _facade = db_session.EngineFacade(CONF.database.connection)
# _facade = db_session.EngineFacade.from_config(CONF)
_facade = db_session.EngineFacade(
"mysql://vdibroker:Passw0rd@localhost/vdibroker")
return _facade
示例7: _create_facade_lazily
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def _create_facade_lazily():
global _FACADE
if _FACADE is None:
_FACADE = db_session.EngineFacade(
CONF.database.connection,
**dict(CONF.database))
return _FACADE
示例8: setUp
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def setUp(self):
super(EngineFacadeTestCase, self).setUp()
self.facade = session.EngineFacade('sqlite://')
示例9: test_direct_invocation_deprecated_args
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def test_direct_invocation_deprecated_args(self):
facade = session.EngineFacade("sqlite://", idle_timeout=59)
self.assertEqual(59, facade.get_engine().pool._recycle)
示例10: test_creation_from_config
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def test_creation_from_config(self, create_engine, get_maker):
conf = cfg.ConfigOpts()
conf.register_opts(db_options.database_opts, group='database')
overrides = {
'connection': 'sqlite:///:memory:',
'slave_connection': None,
'connection_debug': 100,
'max_pool_size': 10,
'mysql_sql_mode': 'TRADITIONAL',
}
for optname, optvalue in overrides.items():
conf.set_override(optname, optvalue, group='database')
session.EngineFacade.from_config(conf,
autocommit=False,
expire_on_commit=True)
create_engine.assert_called_once_with(
sql_connection='sqlite:///:memory:',
connection_debug=100,
max_pool_size=10,
mysql_sql_mode='TRADITIONAL',
mysql_enable_ndb=False,
sqlite_fk=False,
connection_recycle_time=mock.ANY,
retry_interval=mock.ANY,
max_retries=mock.ANY,
max_overflow=mock.ANY,
connection_trace=mock.ANY,
sqlite_synchronous=mock.ANY,
pool_timeout=mock.ANY,
thread_checkin=mock.ANY,
json_serializer=None,
json_deserializer=None,
connection_parameters='',
logging_name=mock.ANY,
)
get_maker.assert_called_once_with(engine=create_engine(),
autocommit=False,
expire_on_commit=True)
示例11: test_slave_connection_string_not_provided
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def test_slave_connection_string_not_provided(self):
master_path = 'sqlite:///' + self.create_tempfiles(
[('db.master', '')], ext='')[0]
facade = session.EngineFacade(sql_connection=master_path)
master = facade.get_engine()
slave = facade.get_engine(use_slave=True)
self.assertIs(master, slave)
self.assertEqual(master_path, str(master.url))
master_session = facade.get_session()
self.assertEqual(master_path, str(master_session.bind.url))
slave_session = facade.get_session(use_slave=True)
self.assertEqual(master_path, str(slave_session.bind.url))
示例12: get_facade
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def get_facade():
global _facade
if not _facade:
_facade = db_session.EngineFacade(CONF.database.connection)
return _facade
示例13: _create_facade_lazily
# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import EngineFacade [as 別名]
def _create_facade_lazily():
global _LOCK
with _LOCK:
global _FACADE
if _FACADE is None:
_FACADE = db_session.EngineFacade(
CONF.database.connection,
**dict(CONF.database)
)
return _FACADE