NubDB Python Client
🚀 Python client for NubDB — a blazing-fast, AOF-based in-memory database written in Zig.
Installation
pip install nubdb
Quick Start
Make sure your NubDB server is running (default: localhost:6379), then:
from nubdb import NubDB
# Connect to NubDB
db = NubDB()
# Set and get values
db.set("name", "Alice")
print(db.get("name")) # → Alice
# Use TTL (auto-expire in 60 seconds)
db.set("session", "abc123", ttl=60)
# Counters
db.set("views", 0)
db.incr("views") # → 1
db.incr("views") # → 2
db.decr("views") # → 1
# Check existence
db.exists("name") # → True
db.exists("nope") # → False
# Database size
db.size() # → 3
# Delete keys
db.delete("name")
# Close when done
db.close()
Context Manager
from nubdb import NubDB
with NubDB() as db:
db.set("key", "value")
print(db.get("key"))
# Connection automatically closed
Configuration
from nubdb import NubDB
# Custom host and port
db = NubDB(host="db.nubcoder.com", port=6379)
# With timeout and retry settings
db = NubDB(
host="localhost",
port=6379,
timeout=10.0, # Socket timeout (seconds)
auto_reconnect=True, # Auto-reconnect on connection loss
max_retries=5, # Max reconnection attempts
)
Environment Variables
| Variable | Default | Description |
|---|---|---|
NUBDB_HOST |
localhost |
Server hostname |
NUBDB_PORT |
6379 |
Server port |
export NUBDB_HOST=db.nubcoder.com
export NUBDB_PORT=6379
API Reference
Connection
| Method | Description |
|---|---|
NubDB(host, port, ...) |
Create client and connect |
db.connect() |
Reconnect to server |
db.close() |
Close connection |
db.ping() |
Check server is reachable |
db.connected |
Connection status (property) |
Commands
| Method | Returns | Description |
|---|---|---|
db.set(key, value, ttl=None) |
bool |
Set a key-value pair |
db.get(key) |
str | None |
Get value by key |
db.delete(key) |
bool |
Delete a key |
db.exists(key) |
bool |
Check if key exists |
db.incr(key) |
int |
Increment integer value |
db.decr(key) |
int |
Decrement integer value |
db.size() |
int |
Get number of keys |
db.clear() |
bool |
Delete all keys |
Bulk Operations
| Method | Returns | Description |
|---|---|---|
db.mset({"k1": "v1", ...}) |
bool |
Set multiple key-value pairs |
db.mget("k1", "k2", ...) |
dict |
Get multiple keys at once |
Error Handling
from nubdb import NubDB, ConnectionError, TimeoutError, CommandError
try:
db = NubDB()
db.set("key", "value")
except ConnectionError:
print("Could not connect to NubDB server")
except TimeoutError:
print("Command timed out")
except CommandError as e:
print(f"Command failed: {e}")
Requirements
- Python 3.8+
- Running NubDB server (setup guide)
- Zero dependencies — uses only Python standard library
NubDB Server
NubDB is a high-performance, AOF-based in-memory database written in Zig:
- 100k+ ops/sec throughput
- <5µs SET latency, <1µs GET latency
- AOF persistence with background compaction
- Docker & Kubernetes ready
# Start NubDB server with Docker
docker run -d -p 6379:6379 nubdb:latest
# Or build from source
git clone https://github.com/nub-coders/nubdt.git
cd nubdt && make server
License
MIT License — see LICENSE for details.
Metadata
Release files for nubdt 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nubdt-1.0.1.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nubdt-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / nubdt-1.0.1.tar.gz
| Download URL | nubdt-1.0.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66f268d1fccbd407954001323d4049a51e0de250a87a30ab6aca7b3df0e2004e
|
|
BLAKE2b-256 checksum How to use checksums |
b02f82231b26041f47fd3cbd4ae806817313bcffd418b0464e5aa785170b5239
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 13, 2026.
Transparency logRelease files / nubdt-1.0.1-py3-none-any.whl
| Download URL | nubdt-1.0.1-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a139d50e80f15dafd41684ab613c2e9f4a7fa7b25a5ba822507253ed0fee4f7b
|
|
BLAKE2b-256 checksum How to use checksums |
df1ae50bbae1c87c52e70cf10a2f6b3744e09bc48a324c7df29dc63a1aa2e814
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 13, 2026.
Transparency log