Skip to content

vantagecompute/dqlitepy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

dqlitepy

Python bindings for dqlite - Distributed SQLite

License Python PyPI

Build Status GitHub Issues Pull Requests GitHub Contributors


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

Full 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

πŸ› οΈ 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 coverage
  • just lint - Check code style
  • just typecheck - Run static type checking
  • just fmt - Format code
  • just 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