本文整理汇总了Python中orator.Model.set_connection_resolver方法的典型用法代码示例。如果您正苦于以下问题:Python Model.set_connection_resolver方法的具体用法?Python Model.set_connection_resolver怎么用?Python Model.set_connection_resolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orator.Model
的用法示例。
在下文中一共展示了Model.set_connection_resolver方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dump
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def dump(db_path):
"""Dump the DB contents to STDOUT, requiring only that the DB is a version that
has an otus table in sqlite3 form (i.e. version 2 and 3 at least).
"""
sqlite_db = os.path.join(db_path, SequenceDatabase.SQLITE_DB_NAME)
logging.debug("Connecting to DB {}".format(sqlite_db))
if not os.path.exists(sqlite_db):
raise Exception("SQLite3 database does not appear to exist in the SingleM database - perhaps it is the wrong version?")
db = DatabaseManager({
'sqlite3': {
'driver': 'sqlite',
'database': sqlite_db
}})
Model.set_connection_resolver(db)
print "\t".join(OtuTable.DEFAULT_OUTPUT_FIELDS)
for chunk in db.table('otus').chunk(1000):
for entry in chunk:
otu = OtuTableEntry()
otu.marker = entry.marker
otu.sample_name = entry.sample_name
otu.sequence = entry.sequence
otu.count = entry.num_hits
otu.coverage = entry.coverage
otu.taxonomy = entry.taxonomy
print str(otu)
示例2: _connect_to_sqlite
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def _connect_to_sqlite(self, db):
sqlite_db_path = db.sqlite_file
if not os.path.exists(sqlite_db_path):
raise Exception("Sqlite database not found at '%s', indicating that either the SingleM database was built with an out-dated SingleM version, or that the database is corrupt. Please generate a new database with the current version of SingleM.")
logging.debug("Connecting to %s" % sqlite_db_path)
dbm = DatabaseManager({
'sqlite3': {
'driver': 'sqlite',
'database': sqlite_db_path
}})
Model.set_connection_resolver(dbm)
try:
len(dbm.table('otus').limit(1).get())
except Exception as e:
logging.error("Failure to extract any data from the otus table of the SQ Lite DB indicates this SingleM DB is either too old or is corrupt.")
raise(e)
try:
len(dbm.table('clusters').limit(1).get())
except QueryException:
logging.error("Failure to extract any data from the 'clusters' table indicates this SingleM DB is out-dated, and cannot be used with query implemented in this version of SingleM")
sys.exit(1)
return dbm
示例3: setUpClass
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def setUpClass(cls):
cls.db = DatabaseIntegrationConnectionResolver({}, cache=cache)
Model.set_connection_resolver(cls.db)
示例4: WhatsAPIDriver
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
from orator import DatabaseManager, Model
from webwhatsapi import WhatsAPIDriver
driver = WhatsAPIDriver(username="hifenhur")
config = {
'postgres': {
'driver': 'postgres',
'host': '35.247.235.153',
'database': 'tbc_wpp',
'user': 'hifenhur',
'password': 'numero04',
}
}
class Driver(Model):
pass
db = DatabaseManager(config)
Model.set_connection_resolver(db)
示例5: setUpClass
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def setUpClass(cls):
Model.set_connection_resolver(DatabaseIntegrationConnectionResolver())
示例6: setUpClass
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def setUpClass(cls):
Model.set_connection_resolver(DatabaseIntegrationConnectionWithoutForeignKeysResolver())
示例7: setup_database
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def setup_database():
"""Setup a connection with the database"""
db = DatabaseManager(config.DATABASES)
Model.set_connection_resolver(db)
return db
示例8: load_dotenv
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
|
'''
load_dotenv(find_dotenv())
'''
|--------------------------------------------------------------------------
| Database Settings
|--------------------------------------------------------------------------
|
| Set connection database settings here as a dictionary. Follow the
| format below to create additional connection settings.
|
| @see Orator migrations documentation for more info
|
'''
DATABASES = {
'default': {
'driver': os.environ.get('DB_DRIVER'),
'host': os.environ.get('DB_HOST'),
'database': os.environ.get('DB_DATABASE'),
'user': os.environ.get('DB_USERNAME'),
'password': os.environ.get('DB_PASSWORD'),
'prefix': ''
}
}
DB = DatabaseManager(DATABASES)
Model.set_connection_resolver(DB)
示例9: setUpClass
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def setUpClass(cls):
Model.set_connection_resolver(cls.get_connection_resolver())
示例10: setUp
# 需要导入模块: from orator import Model [as 别名]
# 或者: from orator.Model import set_connection_resolver [as 别名]
def setUp(self):
self.db = DatabaseManager(self.databases)
Model.set_connection_resolver(self.db)
self.create_schema()