当前位置: 首页>>代码示例>>Python>>正文


Python orator.Model类代码示例

本文整理汇总了Python中orator.Model的典型用法代码示例。如果您正苦于以下问题:Python Model类的具体用法?Python Model怎么用?Python Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Model类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dump

    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)
开发者ID:wwood,项目名称:singlem,代码行数:26,代码来源:sequence_database.py

示例2: test_reconnection

    def test_reconnection(self):
        db = Model.get_connection_resolver()

        db.disconnect()
        db.reconnect()

        db.disconnect()
开发者ID:kdriedger-simutech,项目名称:orator,代码行数:7,代码来源:__init__.py

示例3: _connect_to_sqlite

 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
开发者ID:wwood,项目名称:singlem,代码行数:22,代码来源:querier.py

示例4: tearDownClass

 def tearDownClass(cls):
     Model.unset_connection_resolver()
开发者ID:sdispater,项目名称:orator-cache,代码行数:2,代码来源:test_cache.py

示例5: setUpClass

 def setUpClass(cls):
     cls.db = DatabaseIntegrationConnectionResolver({}, cache=cache)
     Model.set_connection_resolver(cls.db)
开发者ID:sdispater,项目名称:orator-cache,代码行数:3,代码来源:test_cache.py

示例6: connection

 def connection(self):
     return Model.get_connection_resolver().connection()
开发者ID:sdispater,项目名称:orator-cache,代码行数:2,代码来源:test_cache.py

示例7: WhatsAPIDriver

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)

开发者ID:hifenhur,项目名称:wppbot,代码行数:20,代码来源:tbc.py

示例8: setUpClass

 def setUpClass(cls):
     Model.set_connection_resolver(DatabaseIntegrationConnectionResolver())
开发者ID:southwestjiaotongunivercity,项目名称:orator,代码行数:2,代码来源:test_mysql.py

示例9: setUpClass

 def setUpClass(cls):
     Model.set_connection_resolver(DatabaseIntegrationConnectionWithoutForeignKeysResolver())
开发者ID:southwestjiaotongunivercity,项目名称:orator,代码行数:2,代码来源:test_sqlite.py

示例10: setup_database

def setup_database():
    """Setup a connection with the database"""
    db = DatabaseManager(config.DATABASES)
    Model.set_connection_resolver(db)
    return db
开发者ID:camilstaps,项目名称:pyble,代码行数:5,代码来源:cli.py

示例11: load_dotenv

|
'''

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)
开发者ID:vaibhavmule,项目名称:learning-python,代码行数:30,代码来源:database.py

示例12: setUpClass

 def setUpClass(cls):
     Model.set_connection_resolver(cls.get_connection_resolver())
开发者ID:dougblack,项目名称:orator,代码行数:2,代码来源:__init__.py

示例13: tearDown

    def tearDown(self):
        self.schema().drop('users')
        self.schema().drop('posts')
        self.schema().drop('comments')

        Model.unset_connection_resolver()
开发者ID:dougblack,项目名称:orator,代码行数:6,代码来源:test_soft_deletes_integration.py

示例14: setUp

    def setUp(self):
        self.db = DatabaseManager(self.databases)

        Model.set_connection_resolver(self.db)

        self.create_schema()
开发者ID:dougblack,项目名称:orator,代码行数:6,代码来源:test_soft_deletes_integration.py


注:本文中的orator.Model类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。