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:
- Downloads the correct
titan-nodebinary for your OS (Windows/Mac/Linux) - Starts a 3-node distributed cluster on localhost
- 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
- Repository: github.com/Yogendra-sodha/titan-distributed-sqlite
- Dashboard: Open
http://127.0.0.1:8001/when the cluster is running
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 titan_db-0.2.0.tar.gz.
File metadata
- Download URL: titan_db-0.2.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9635b3f5a9afcfb6e6d3f66c41f036fa64a5d352de16ec9807f65192411c0f0
|
|
| MD5 |
28655c7b685f3a2cabe02e184c2e9f95
|
|
| BLAKE2b-256 |
ac4b53295e3e3d9e0f8b3dd37a2246930ed62d57255af9083344a2d8dff3b20c
|
Provenance
The following attestation bundles were made for titan_db-0.2.0.tar.gz:
Publisher:
pypi-publish.yml on Yogendra-sodha/titan-distributed-sqlite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
titan_db-0.2.0.tar.gz -
Subject digest:
c9635b3f5a9afcfb6e6d3f66c41f036fa64a5d352de16ec9807f65192411c0f0 - Sigstore transparency entry: 1340115631
- Sigstore integration time:
-
Permalink:
Yogendra-sodha/titan-distributed-sqlite@e645a9e1614aef393479e7368a24b481d703d993 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Yogendra-sodha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@e645a9e1614aef393479e7368a24b481d703d993 -
Trigger Event:
release
-
Statement type:
File details
Details for the file titan_db-0.2.0-py3-none-any.whl.
File metadata
- Download URL: titan_db-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.2 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 |
13b6469619abb22fcf89c78d5a19c7474fe9cc3ba57eb289da9e8ba20b89d125
|
|
| MD5 |
cb1dc72b12a16c544087a967cbdb66a5
|
|
| BLAKE2b-256 |
b17b3b229da8c4a6a7d5137a264d1249fd59ded9a4145a8abb2a5d52f9d71f02
|
Provenance
The following attestation bundles were made for titan_db-0.2.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on Yogendra-sodha/titan-distributed-sqlite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
titan_db-0.2.0-py3-none-any.whl -
Subject digest:
13b6469619abb22fcf89c78d5a19c7474fe9cc3ba57eb289da9e8ba20b89d125 - Sigstore transparency entry: 1340115639
- Sigstore integration time:
-
Permalink:
Yogendra-sodha/titan-distributed-sqlite@e645a9e1614aef393479e7368a24b481d703d993 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Yogendra-sodha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@e645a9e1614aef393479e7368a24b481d703d993 -
Trigger Event:
release
-
Statement type: