简体   繁体   English

无法通过 Gino(异步 sqlalchemy 包装器)连接到 SQLite 数据库

[英]Can't connect to SQLite database through Gino (async sqlalchemy wrapper)

I was following the documentation for Gino (an asynchronous sqlalchemy wrapper), and when I just try to connect to an sqlite database, I get an error.我正在关注 Gino(一个异步 sqlalchemy 包装器)的文档,当我尝试连接到 sqlite 数据库时,出现错误。 Here's the code:这是代码:

db = Gino()


class Server(db.Model):
    __tablename__ = 'servers'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.Unicode(), default='noname')


async def main():
    await db.set_bind('sqlite:///:memory:')
    await db.gino.create_all()

asyncio.get_event_loop().run_until_complete(main())

Here's the error:这是错误:

AttributeError: 'SQLiteDialect_pysqlite' object has no attribute 'init_pool'

Does this mean for sure that Gino does not support the use of an SQLite database, or could something else be going wrong?这是否意味着 Gino 肯定不支持使用 SQLite 数据库,或者可能出现其他问题?

Right at the top of their README :就在他们README的顶部:

Now (early 2018) GINO supports only one dialect asyncpg.现在(2018 年初)GINO 仅支持一种方言 asyncpg。

Granted, it's now early 2019, but that doesn't look to have changed:诚然,现在是 2019 年初,但这似乎并没有改变:

├── gino
│   ├── dialects
│   │   ├── __init__.py
│   │   ├── asyncpg.py
│   │   └── base.py

In asyncpg.py they import PGDialect from sqlalchemy and extend from that to make a class called AsyncPGDialect which defines the init_pool method.asyncpg.py他们从asyncpg.py导入PGDialect并从中扩展以创建一个名为AsyncPGDialect的类,该类定义了init_pool方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM