Async Python client for dqlite with connection pooling and leader detection
Project description
dqlite-client
Async Python client for dqlite, Canonical's distributed SQLite. It connects to a dqlite cluster, finds the current Raft leader, runs SQL, and pools connections.
The API is inspired by asyncpg's
ergonomics — explicit connect() / create_pool(), fetch / fetchall
/ fetchval, and context-manager transactions — with a deliberately
simple data model: fetch returns list[dict], fetchall returns
list[list], fetchval returns a scalar. There is no Record type.
Is this the package you want?
Use dqlite-client directly when you want a lightweight async client
with no ORM or DB-API layer, or when you need fine-grained control over
cluster bootstrapping and the wire protocol.
If you want a standard PEP 249 driver, SQLAlchemy, Alembic, or most ORMs, reach for a higher layer instead — see The dqlite Python stack below.
Installation
pip install dqlite-client
Requires Python 3.13+.
Usage
import asyncio
from dqliteclient import connect
async def main():
conn = await connect("localhost:9001")
async with conn.transaction():
await conn.execute("CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, name TEXT)")
await conn.execute("INSERT INTO t (name) VALUES (?)", ["hello"])
rows = await conn.fetch("SELECT * FROM t") # list[dict]
for row in rows:
print(row)
await conn.close()
asyncio.run(main())
Connection pool
from dqliteclient import create_pool
pool = await create_pool(["localhost:9001", "localhost:9002", "localhost:9003"])
async with pool.acquire() as conn:
rows = await conn.fetch("SELECT 1")
The dqlite Python stack
This is one of four layered packages. Each builds on the one below:
| Package | Role |
|---|---|
| sqlalchemy-dqlite | SQLAlchemy 2.0 dialect |
| dqlite-dbapi | PEP 249 (DB-API 2.0) driver — sync & async |
| dqlite-client — this package | Async wire client — pooling, leader discovery |
| dqlite-wire | Wire-protocol codec |
For SQLAlchemy/ORM use, prefer sqlalchemy-dqlite or dqlite-dbapi.
Documentation
- Connection pooling — sizing, startup, and leader behavior.
- Deployment: forking & multiprocessing — read this
if you use gunicorn, Celery, or
multiprocessing. - Data types & NULL handling — the row model and a server-version gotcha for NULLs in typed columns.
Development
See DEVELOPMENT.md for setup and contribution guidelines.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dqlite_client-0.3.0.tar.gz.
File metadata
- Download URL: dqlite_client-0.3.0.tar.gz
- Upload date:
- Size: 411.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7baa1c09446373fce1527a4e000c7da54df74b265de3ecef8901ae3665ea65f5
|
|
| MD5 |
80f25b089c272652eab9e4765fd11993
|
|
| BLAKE2b-256 |
0a1881e2b72298170471186a19b1ab01532e2905adaf60742161711ec94f101b
|
Provenance
The following attestation bundles were made for dqlite_client-0.3.0.tar.gz:
Publisher:
publish-to-pypi.yml on letsdiscodev/python-dqlite-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dqlite_client-0.3.0.tar.gz -
Subject digest:
7baa1c09446373fce1527a4e000c7da54df74b265de3ecef8901ae3665ea65f5 - Sigstore transparency entry: 1700269974
- Sigstore integration time:
-
Permalink:
letsdiscodev/python-dqlite-client@28fcbaae36ba299a063c3aadea903403d0b04883 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/letsdiscodev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@28fcbaae36ba299a063c3aadea903403d0b04883 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dqlite_client-0.3.0-py3-none-any.whl.
File metadata
- Download URL: dqlite_client-0.3.0-py3-none-any.whl
- Upload date:
- Size: 100.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4f764dfaea123bb8f1be61a979a5fd1fbd3e80a526e3bac59e89a0460783c8a
|
|
| MD5 |
ec793ad42adf03ce74e1fe0d1040adfb
|
|
| BLAKE2b-256 |
364cf2c14350035524ea10713f1e0e8be4a5777f1450f67b688b7138eb5f35a1
|
Provenance
The following attestation bundles were made for dqlite_client-0.3.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on letsdiscodev/python-dqlite-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dqlite_client-0.3.0-py3-none-any.whl -
Subject digest:
f4f764dfaea123bb8f1be61a979a5fd1fbd3e80a526e3bac59e89a0460783c8a - Sigstore transparency entry: 1700270057
- Sigstore integration time:
-
Permalink:
letsdiscodev/python-dqlite-client@28fcbaae36ba299a063c3aadea903403d0b04883 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/letsdiscodev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@28fcbaae36ba299a063c3aadea903403d0b04883 -
Trigger Event:
push
-
Statement type: