A simple async wrapper for sqlite3
Project description
asqlite
This package is a fork of rapptz's asqlite. asqlite is 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:
# Create table
await cursor.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
await cursor.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
# Save (commit) the changes
await conn.commit()
asyncio.run(main())
Differences from sqlite3
This module differs from sqlite3
in a few ways:
- Connections are created with
journal_mode
set towal
. - Connections have foreign keys enabled by default.
- Implicit transactions are turned off
- The
row_factory
is set tosqlite3.Row
.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rapptz-asqlite-0.0.2.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for rapptz_asqlite-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e181e98fbcb698d1bf5a69fe00557b90c4ed73e2d50b49c43789409183610d0 |
|
MD5 | d681da3ad12a2c669f50b4819ab19723 |
|
BLAKE2b-256 | a67e1064a6e20c0b664745c4907dae345b26b842bcbd1e0b5679f7b3a1cd4876 |