Skip to main content

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

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

dqlite_client-0.3.0.tar.gz (411.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dqlite_client-0.3.0-py3-none-any.whl (100.2 kB view details)

Uploaded Python 3

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

Hashes for dqlite_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7baa1c09446373fce1527a4e000c7da54df74b265de3ecef8901ae3665ea65f5
MD5 80f25b089c272652eab9e4765fd11993
BLAKE2b-256 0a1881e2b72298170471186a19b1ab01532e2905adaf60742161711ec94f101b

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for dqlite_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4f764dfaea123bb8f1be61a979a5fd1fbd3e80a526e3bac59e89a0460783c8a
MD5 ec793ad42adf03ce74e1fe0d1040adfb
BLAKE2b-256 364cf2c14350035524ea10713f1e0e8be4a5777f1450f67b688b7138eb5f35a1

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page