當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。