Skip to main content

Python client & server manager for Titan Distributed SQLite

Project description

Titan DB — Python Client

Zero-setup distributed SQLite. Install with pip, start a fault-tolerant cluster with one command.

Install

pip install titan-db

Start the Server (One Command!)

titan-server start

This automatically:

  1. Downloads the correct titan-node binary for your OS (Windows/Mac/Linux)
  2. Starts a 3-node distributed cluster on localhost
  3. Prints the connection URLs

To stop the cluster:

titan-server stop

To check health:

titan-server status

Use the Client

from titan_db import TitanClient

# Connect to the cluster
db = TitanClient([
    "http://127.0.0.1:8001",
    "http://127.0.0.1:8002",
    "http://127.0.0.1:8003",
])

# Write — automatically finds and routes to the Leader node
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)")
db.execute("INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com')")

# Read — queries any reachable node
rows = db.query("SELECT * FROM users")
print(rows)
# [{'id': '1', 'name': 'Alice', 'email': 'alice@example.com'}]

# Transactions — multiple statements, atomic
db.transaction([
    "INSERT INTO users (name, email) VALUES ('Bob', 'bob@example.com')",
    "INSERT INTO users (name, email) VALUES ('Charlie', 'charlie@example.com')",
])

# Cluster health
print(db.status())
print(db.leader())

Start the Server from Python

You can also manage the cluster programmatically:

from titan_db.server import TitanServer
from titan_db import TitanClient

# Use as a context manager — auto starts and stops
with TitanServer() as server:
    db = TitanClient(server.node_urls())
    db.execute("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)")
    db.execute("INSERT INTO test (value) VALUES ('hello distributed world!')")
    print(db.query("SELECT * FROM test"))
# Cluster automatically stops when the block exits

Authentication

If the server is started with TITAN_API_KEY, pass it to the client:

db = TitanClient(
    nodes=["http://127.0.0.1:8001", "http://127.0.0.1:8002", "http://127.0.0.1:8003"],
    api_key="my_secret_key"
)

API Reference

Method Description
execute(sql) Write SQL — auto-routes to Leader via Raft
query(sql) Read SQL — returns list of dicts
transaction([...]) Atomic multi-statement transaction
status() All nodes health
leader() Current leader info

CLI Reference

Command Description
titan-server start Download binary + start 3-node cluster
titan-server stop Stop all running nodes
titan-server status Check cluster health
titan-server download Just download the binary (no start)

Troubleshooting

Error Cause Fix
No Titan nodes are reachable Cluster not running Run titan-server start
Nodes reachable but no Leader Election in progress Wait 1-2 seconds, retry
Binary not found for your platform No pre-built binary Build from source (see error message)
Unauthorized API key required Pass api_key= to TitanClient

Links

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

titan_db-0.3.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

titan_db-0.3.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file titan_db-0.3.2.tar.gz.

File metadata

  • Download URL: titan_db-0.3.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for titan_db-0.3.2.tar.gz
Algorithm Hash digest
SHA256 bafa0bfdf1e02b3bfdd9c04f65fd414ae03b23f702d9a10af25d5d8640b83948
MD5 aa765a2ae7fc64e8fa6b2a3badd6881b
BLAKE2b-256 93baaa268421842d95f9e45c91566ae1ffa7da848765599d9c32c3f5ac0c02f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for titan_db-0.3.2.tar.gz:

Publisher: pypi-publish.yml on Yogendra-sodha/titan-distributed-sqlite

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

File details

Details for the file titan_db-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: titan_db-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for titan_db-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 171512a7f4a459ff7f8d04f87bb4fcb0d6810b86f5aefb797ea2cd7473f3a268
MD5 636b96e39fbc4ca02e5f6a0b451a7be0
BLAKE2b-256 59983e8f2da8330916c89a9d18c34ea9d435896584905ccd2f30087bf55b2986

See more details on using hashes here.

Provenance

The following attestation bundles were made for titan_db-0.3.2-py3-none-any.whl:

Publisher: pypi-publish.yml on Yogendra-sodha/titan-distributed-sqlite

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