Skip to main content

dqlite-dbapi

A PEP 249 (DB-API 2.0) driver for dqlite, Canonical's distributed SQLite. If you have used Python's standard sqlite3 module, this will feel familiar — same connect() / cursor() / execute() / fetchone() shape — but it talks to a replicated dqlite cluster over the network instead of a local file.

It comes in two flavors from one package: a synchronous API (dqlitedbapi) and an async API (dqlitedbapi.aio).

Is this the package you want?

Yes, if you want a drop-in-style database driver for dqlite — directly, or under a tool that expects a DB-API 2.0 driver. For SQLAlchemy specifically, use sqlalchemy-dqlite (it builds on this package).

Installation

pip install dqlite-dbapi

Requires Python 3.13+.

Usage

Sync

import dqlitedbapi

conn = dqlitedbapi.connect("localhost:9001")
cur = conn.cursor()
cur.execute("SELECT 1")
print(cur.fetchone())
conn.close()

Async

import asyncio
from dqlitedbapi.aio import aconnect

async def main():
    conn = await aconnect("localhost:9001")
    cur = conn.cursor()
    await cur.execute("SELECT 1")
    print(await cur.fetchone())
    await conn.close()

asyncio.run(main())

Key facts

  • apilevel = "2.0", paramstyle = "qmark" (? placeholders), threadsafety = 2.
  • Autocommit by default. Unlike stdlib sqlite3, the driver does not auto-BEGIN before a statement — wrap writes in an explicit transaction when you need atomic multi-statement semantics. See Transactions.
  • Isolation is always SERIALIZABLE — every write goes through Raft consensus, every read is serializable.

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 — this package PEP 249 (DB-API 2.0) driver — sync & async
dqlite-client Async wire client — pooling, leader discovery
dqlite-wire Wire-protocol codec

Using SQLAlchemy or an ORM? Prefer sqlalchemy-dqlite.

Documentation

Development

See DEVELOPMENT.md for setup and contribution guidelines.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dqlite_dbapi-0.5.0.tar.gz (140.9 kB view details)

Uploaded Source

Built Distribution

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

dqlite_dbapi-0.5.0-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file dqlite_dbapi-0.5.0.tar.gz.

File metadata

  • Download URL: dqlite_dbapi-0.5.0.tar.gz
  • Upload date:
  • Size: 140.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dqlite_dbapi-0.5.0.tar.gz
Algorithm Hash digest
SHA256 12db9b31109d400449fd9db87f6f464b278715f81b4c50b4f67d58c2585eb5ac
MD5 18f3693c783d9866650d2df64b927239
BLAKE2b-256 2cdf6e1909c267df98ca9def0c52f35756863b3a9aff749845f929743f3e6378

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_dbapi-0.5.0.tar.gz:

Publisher: publish-to-pypi.yml on letsdiscodev/python-dqlite-dbapi

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_dbapi-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: dqlite_dbapi-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dqlite_dbapi-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc2a612b4cc88aeb635f10e73aa85d999609955fcf3264c92bc6b25c04a77e5
MD5 1bff9743e71977b7b17170db0adb826d
BLAKE2b-256 63ff10e5122cb77373baa5cee61bbc83845db1a864229c708bf527008f00960c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dqlite_dbapi-0.5.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on letsdiscodev/python-dqlite-dbapi

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

Release history Release notifications | RSS feed

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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