Python bindings for the Canonical dqlite distributed SQLite engine
Project description
Python bindings for the dqlite distributed SQLite engine. Ships with a self-contained Go shim that bundles the native runtime—no system dependencies required.
📚 Documentation
Complete guides, API reference, clustering setup, and examples.
✨ Features
- 🚀 Node Management - Create and manage dqlite nodes
- 🔗 Cluster Support - Programmatically form and manage clusters
- 📦 Self-Contained - No system dependencies required
- 🔒 Thread-Safe - Safe for concurrent use
- 🐍 DB-API 2.0 - Standard Python database interface
- 🎯 SQLAlchemy Support - Use with your favorite ORM
🚀 Quick Start
Installation
pip install dqlitepy
Basic Usage
import dqlitepy
# Connect using DB-API 2.0
conn = dqlitepy.connect(
address="127.0.0.1:9001",
data_dir="/tmp/dqlite-data"
)
cursor = conn.cursor()
cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)")
cursor.execute("INSERT INTO users (name) VALUES (?)", ("Alice",))
conn.commit()
cursor.execute("SELECT * FROM users")
print(cursor.fetchall())
conn.close()
Node Management
from dqlitepy import Node
from pathlib import Path
# Create and start a node
with Node(
address="127.0.0.1:9001",
data_dir=Path("/tmp/dqlite-data"),
) as node:
print(f"Node {node.id} running at {node.address}")
Clustering
from dqlitepy import Node, Client
# Start bootstrap node
node1 = Node("127.0.0.1:9001", "/data/node1")
node1.start()
# Connect client and add more nodes
with Client(["127.0.0.1:9001"]) as client:
node2 = Node("127.0.0.1:9002", "/data/node2")
node2.start()
client.add(node2.id, "127.0.0.1:9002")
# Query cluster state
leader = client.leader()
nodes = client.cluster()
print(f"Leader: {leader}")
for n in nodes:
print(f" Node {n.id}: {n.address} ({n.role_name})")
📖 Learn More
- Getting Started Guide - Detailed tutorial
- API Reference - Complete API documentation
- Clustering Guide - Multi-node setup
- Examples - Code examples and patterns
🛠️ Development
Building from Source
git clone https://github.com/vantagecompute/dqlitepy.git
cd dqlitepy
# Build native library using Docker
just build-lib
# Install in development mode
uv pip install -e .
Running Tests
# Run test suite
just unit
# Run linting and type checking
just lint
just typecheck
Project Commands
The project uses just for task automation:
sudo snap install just --classic
just unit- Run tests with coveragejust lint- Check code stylejust typecheck- Run static type checkingjust fmt- Format codejust build-lib- Build native library (Docker)just docs-dev- Start documentation dev server
See the justfile for all available commands.
📝 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Copyright 2025 Vantage Compute
🤝 Contributing
Contributions welcome! Please see our Contributing Guide for details.
💬 Support
- GitHub Issues - Bug reports and feature requests
- Documentation - Comprehensive guides and API reference
- Examples - Sample code and use cases
Project details
Release history Release notifications | RSS feed
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 dqlitepy-0.1.0.tar.gz.
File metadata
- Download URL: dqlitepy-0.1.0.tar.gz
- Upload date:
- Size: 879.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8996c48b44c09ef2d8338c00126b0742f92fdb319885589a85a1d992834d2916
|
|
| MD5 |
5470f471141d64bcad8ec80bf3cdf41a
|
|
| BLAKE2b-256 |
a0b0fa61eafd92f5862c6749523761fd4ccd101c1354fbfa166a755f4b4fa8ba
|
File details
Details for the file dqlitepy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dqlitepy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 887.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
740fe255cdf73d07c5999461d2d87f6e012fc7caafb2411991d51f2686ce9733
|
|
| MD5 |
9fa75b8cd165fd08a78010f0c7aabf1a
|
|
| BLAKE2b-256 |
908e12d276c0756e6caada38d2058829be2d219baee84d49438883925faf19c1
|