[英]Can't connect to SQLite database through Gino (async sqlalchemy wrapper)
我正在關注 Gino(一個異步 sqlalchemy 包裝器)的文檔,當我嘗試連接到 sqlite 數據庫時,出現錯誤。 這是代碼:
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())
這是錯誤:
AttributeError: 'SQLiteDialect_pysqlite' object has no attribute 'init_pool'
這是否意味着 Gino 肯定不支持使用 SQLite 數據庫,或者可能出現其他問題?
就在他們README
的頂部:
現在(2018 年初)GINO 僅支持一種方言 asyncpg。
誠然,現在是 2019 年初,但這似乎並沒有改變:
├── gino
│ ├── dialects
│ │ ├── __init__.py
│ │ ├── asyncpg.py
│ │ └── base.py
在asyncpg.py
他們從asyncpg.py
導入PGDialect
並從中擴展以創建一個名為AsyncPGDialect
的類,該類定義了init_pool
方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.