Skip to main content

asyncsqlite3 - asynchronous driver for sqlite3.

Asynchronous interface with context managers for sqlite database:

async with asyncsqlite3.connect(...) as conn:
    async with conn.execute("INSERT INTO some_table ..."):
        await conn.commit()

    async with conn.execute("SELECT * FROM some_table") as cursor:
        rows = await cursor.fetchall()

And without context managers:

conn = await asyncsqlite3.connect(...)
cursor = await conn.execute("SELECT * FROM some_table")
rows = await cursor.fetchall()
await cursor.close()
await conn.close()

Connection pool and transaction:

async with asyncsqlite3.create_pool(..., min_size=1, max_size=2) as pool:
    async with pool.acquire(timeout=1.5) as conn: # You can use a timeout when getting a connection from queue.
        async with conn.transaction():
            async with conn.execute("INSERT INTO some_table ..."):
                ...
    
    async with pool.acquire() as conn:
        async with conn.execute("SELECT id, name FROM some_table") as cursor:
            async for row in cursor:
                print(row) # <Record id=1 name='alex'>
                print(row[0], row["id"], row.get("id")) # 1 1 1
                print(dict(row)) # {'id': 1, 'name': 'alex'}
                print(tuple(row), list(row), set(row)) # (1, 'alex') [1, 'alex'] {1, 'alex'}

Installation

asyncsqlite3 is compatible with Python 3.7 and newer. Use pip to install:

$ pip install asyncsqlite3

You can speed up asyncsqlite3 as follows:

$ pip install asyncsqlite3[uvloop]

Details

How you see this module very look like aiosqlite and asyncpg.

Implicit transactions are turned off, but you can use Connection method transaction.

License

MIT

Metadata

Release files for asyncsqlite3 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncsqlite3 0.1.8
File Size Uploaded Provenance Actions
asyncsqlite3-0.1.8.tar.gz 11.7 kB Without provenance Details for asyncsqlite3-0.1.8.tar.gz

Release files / asyncsqlite3-0.1.8.tar.gz

Download URL asyncsqlite3-0.1.8.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
11e2a587c97aa945567e31e873ad3b0e25ff10c8368b3a2db1296efcc0229f21
BLAKE2b-256 checksum
How to use checksums
ff4bdaf52fbfcebcffe40735b839da92072c9d7220e05126582f7dba672ef24c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0a0

Security for asyncsqlite3 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page