简体   繁体   中英

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. 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?

Right at the top of their README :

Now (early 2018) GINO supports only one dialect asyncpg.

Granted, it's now early 2019, but that doesn't look to have changed:

├── 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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