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


Python db_url.connect方法代码示例

本文整理汇总了Python中playhouse.db_url.connect方法的典型用法代码示例。如果您正苦于以下问题:Python db_url.connect方法的具体用法?Python db_url.connect怎么用?Python db_url.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playhouse.db_url的用法示例。


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

示例1: __init__

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def __init__(self, url):
        self._url = url
        parse_result = urlparse(url)
        self._database_path = parse_result.path[1:]

        # Connect to the database.
        self._database = connect(url)
        self._database.connect()

        # Introspect the database and generate models.
        self._introspector = Introspector.from_database(self._database)
        self._models = self._introspector.generate_models(skip_invalid=True)
        self._migrator = SchemaMigrator.from_database(self._database)

        class BaseModel(Model):
            class Meta:
                database = self._database
        self._base_model = BaseModel
        self._export_formats = self.get_export_formats()
        self._import_formats = self.get_import_formats() 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:22,代码来源:dataset.py

示例2: _load_database

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def _load_database(self, app, config_value):
        if isinstance(config_value, Database):
            database = config_value
        elif isinstance(config_value, dict):
            database = self._load_from_config_dict(dict(config_value))
        else:
            # Assume a database connection URL.
            database = db_url_connect(config_value)

        if isinstance(self.database, Proxy):
            self.database.initialize(database)
        else:
            self.database = database 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:15,代码来源:flask_utils.py

示例3: connect

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def connect(self):
        self._database.connect() 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:4,代码来源:dataset.py

示例4: __enter__

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def __enter__(self):
        self.connect()
        return self 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:5,代码来源:dataset.py

示例5: asyncpg_init

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def asyncpg_init(db_uri):
    import asyncpg

    async def create_conn():
        global asyncpg_conn
        asyncpg_conn = await asyncpg.connect(db_uri)

    async_run(create_conn)


# asyncpg_init(config.DATABASE_URI) 
开发者ID:fy0,项目名称:slim,代码行数:13,代码来源:__init__.py

示例6: init_db

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def init_db(database_url):
    """
        This function initializes the global database with the given url.
    """
    # utility function to parse database urls
    from playhouse.db_url import connect
    # initialize the peewee database with the appropriate engine
    db.initialize(connect(database_url)) 
开发者ID:AlecAivazis,项目名称:graphql-over-kafka,代码行数:10,代码来源:database.py

示例7: setup_db

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def setup_db():
    global home, database
    database_url = config.get("db", "sqlite:///diffengine.db")
    logging.debug("connecting to db %s", database_url)
    database_handler = connect(database_url)
    database.initialize(database_handler)
    database.connect()
    database.create_tables([Feed, Entry, FeedEntry, EntryVersion, Diff], safe=True)

    if isinstance(database_handler, SqliteDatabase):
        try:
            migrator = SqliteMigrator(database_handler)
            migrate(migrator.add_index("entryversion", ("url",), False))
        except OperationalError as e:
            logging.debug(e) 
开发者ID:DocNow,项目名称:diffengine,代码行数:17,代码来源:__init__.py

示例8: create_tables

# 需要导入模块: from playhouse import db_url [as 别名]
# 或者: from playhouse.db_url import connect [as 别名]
def create_tables():
    db.connect()
    db.create_tables([Pokemon, Pokestop, Gym], safe=True)
    db.close() 
开发者ID:favll,项目名称:pogom,代码行数:6,代码来源:models.py


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