Python client for NubDT — a blazing-fast, AOF-based in-memory database written in Zig
Project description
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.
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 nubdt-1.0.1.tar.gz.
File metadata
- Download URL: nubdt-1.0.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66f268d1fccbd407954001323d4049a51e0de250a87a30ab6aca7b3df0e2004e
|
|
| MD5 |
90f503d52374aabdb3d1a364294460c2
|
|
| BLAKE2b-256 |
b02f82231b26041f47fd3cbd4ae806817313bcffd418b0464e5aa785170b5239
|
Provenance
The following attestation bundles were made for nubdt-1.0.1.tar.gz:
Publisher:
pypi-publish.yml on nub-coders/nubdt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nubdt-1.0.1.tar.gz -
Subject digest:
66f268d1fccbd407954001323d4049a51e0de250a87a30ab6aca7b3df0e2004e - Sigstore transparency entry: 949793525
- Sigstore integration time:
-
Permalink:
nub-coders/nubdt@5015b57b66b9f3f5f2f60df6b3941b83cc9f294c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/nub-coders
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@5015b57b66b9f3f5f2f60df6b3941b83cc9f294c -
Trigger Event:
release
-
Statement type:
File details
Details for the file nubdt-1.0.1-py3-none-any.whl.
File metadata
- Download URL: nubdt-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a139d50e80f15dafd41684ab613c2e9f4a7fa7b25a5ba822507253ed0fee4f7b
|
|
| MD5 |
2deccd2d4ff75a951b5c1070a70e8610
|
|
| BLAKE2b-256 |
df1ae50bbae1c87c52e70cf10a2f6b3744e09bc48a324c7df29dc63a1aa2e814
|
Provenance
The following attestation bundles were made for nubdt-1.0.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on nub-coders/nubdt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nubdt-1.0.1-py3-none-any.whl -
Subject digest:
a139d50e80f15dafd41684ab613c2e9f4a7fa7b25a5ba822507253ed0fee4f7b - Sigstore transparency entry: 949793621
- Sigstore integration time:
-
Permalink:
nub-coders/nubdt@5015b57b66b9f3f5f2f60df6b3941b83cc9f294c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/nub-coders
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@5015b57b66b9f3f5f2f60df6b3941b83cc9f294c -
Trigger Event:
release
-
Statement type: