asqlite
A simple and easy to use async wrapper for sqlite3
.
This is basically the same as sqlite3
except you use async with
and await
in front of most operations.
import asyncio
import asqlite
async def main():
async with asqlite.connect('example.db') as conn:
async with conn.cursor() as cursor:
await cursor.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
await cursor.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
await conn.commit()
asyncio.run(main())
Install
To install this via PyPI, use the asqlite
package:
python3 -m pip install -U asqlite
Differences from sqlite3
This module differs from sqlite3
in a few ways:
- Connections are created with
journal_mode
set to wal
. - Connections have foreign keys enabled by default.
- Implicit transactions are turned off
- The
row_factory
is set to sqlite3.Row
. - A
asqlite.Pool
is provided for connection pooling
License
MIT