PEP 249 (DB-API 2.0) compliant interface for dqlite
Project description
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-BEGINbefore 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
- Transactions — the autocommit-by-default model and how to group statements.
- Differences from
sqlite3— what to expect when porting from the stdlib module (and a server-version NULL gotcha). - Differences from
aiosqlite— for the async surface.
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_dbapi-0.3.0.tar.gz.
File metadata
- Download URL: dqlite_dbapi-0.3.0.tar.gz
- Upload date:
- Size: 439.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31b02103f450c3a0c4666406ce8eb224a882287f32d3a55c92a6a5701fa8e49f
|
|
| MD5 |
9f4cf3b970d77ebf9418f5248bc26064
|
|
| BLAKE2b-256 |
daf4c4f52833c0da895c228cd20fc7604c6f2a7ab28399fca6561d1e5cbdefdd
|
Provenance
The following attestation bundles were made for dqlite_dbapi-0.3.0.tar.gz:
Publisher:
publish-to-pypi.yml on letsdiscodev/python-dqlite-dbapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dqlite_dbapi-0.3.0.tar.gz -
Subject digest:
31b02103f450c3a0c4666406ce8eb224a882287f32d3a55c92a6a5701fa8e49f - Sigstore transparency entry: 1700271069
- Sigstore integration time:
-
Permalink:
letsdiscodev/python-dqlite-dbapi@275ed760472a3cafe5f7de86b87fb2cebd7fa9bf -
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@275ed760472a3cafe5f7de86b87fb2cebd7fa9bf -
Trigger Event:
push
-
Statement type:
File details
Details for the file dqlite_dbapi-0.3.0-py3-none-any.whl.
File metadata
- Download URL: dqlite_dbapi-0.3.0-py3-none-any.whl
- Upload date:
- Size: 114.5 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 |
606b802dfc840f8b599a436cac4085beda6b49857332fe0755e52efaa76a4ae7
|
|
| MD5 |
2526ee8c854c5c62da04f7d0e7fab5c5
|
|
| BLAKE2b-256 |
5d886d6d21525377871354beb8357f150845ec4c1500ddb7cdf35827e94fbb1b
|
Provenance
The following attestation bundles were made for dqlite_dbapi-0.3.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on letsdiscodev/python-dqlite-dbapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dqlite_dbapi-0.3.0-py3-none-any.whl -
Subject digest:
606b802dfc840f8b599a436cac4085beda6b49857332fe0755e52efaa76a4ae7 - Sigstore transparency entry: 1700271185
- Sigstore integration time:
-
Permalink:
letsdiscodev/python-dqlite-dbapi@275ed760472a3cafe5f7de86b87fb2cebd7fa9bf -
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@275ed760472a3cafe5f7de86b87fb2cebd7fa9bf -
Trigger Event:
push
-
Statement type: