Skip to main content

Quick Start

Get SochDB running in 5 minutes.


Prerequisites

RequirementVersionCheck Command
Python (optional)3.9 or newerpython --version
Node.js (optional)18 or newernode --version
Go (optional)1.24 or newergo version
Rust (optional)1.85 or newer, edition 2024rustc --version
GitAny recentgit --version

Current SDK versions: Python 0.5.9, Node.js 0.5.3, Go 0.4.5, Rust crate sochdb 2.0.3 (core engine 2.0.3).


Installation

pip install sochdb
note

The PyPI name sochdb ships two importable packages: the pure-Python ctypes SDK (0.5.9, the broad embedded + server SDK used in these examples) and a native PyO3 engine (2.0.3, exposing HnswIndex/BM25Index/TableDatabase/etc.). The examples below use the 0.5.9 SDK's Database class.

Build from Source

git clone https://github.com/sochdb/sochdb
cd sochdb
cargo build --release
note

The core engine (the sochdb crate, server, and MCP) is licensed AGPL-3.0-or-later (commercial licensing available). The language SDKs (Python, Node.js, Go) are Apache-2.0.


Hello World

Each example opens an embedded database, writes a couple of keys, reads one back, then runs an atomic transaction.

from sochdb import Database

# Open database (creates it automatically). Keys and values are bytes.
db = Database.open("./my_first_db")

# Store data
db.put(b"users/alice/name", b"Alice Smith")
db.put(b"users/alice/email", b"alice@example.com")

# Retrieve data
name = db.get(b"users/alice/name")
print(f"Name: {name.decode()}") # Output: Name: Alice Smith

# Atomic transaction (auto-commits on clean exit, auto-aborts on exception).
# Transaction.commit() returns an HLC-backed monotonic commit timestamp.
with db.transaction() as txn:
txn.put(b"users/bob/name", b"Bob Jones")
txn.put(b"users/bob/email", b"bob@example.com")

db.close()

Verify Installation

python -c "import sochdb; print('SochDB Python SDK', sochdb.__version__)"

Configuration

SochDB works out of the box with sensible defaults. For customization:

Environment Variables

# Enable debug logging (standard Rust env filter)
export RUST_LOG=sochdb=debug

# Point the Python FFI loader at a locally built native library
export SOCHDB_LIB_PATH=/path/to/sochdb/target/release

Durability Tuning

Rather than a config file, pass durability options when you open the database. Each SDK exposes the same underlying knobs (sync mode, group commit, index policy):

The 0.5.9 SDK's Database.open takes a config dict with keys such as sync_mode ('off', 'normal', 'full'), wal_enabled, group_commit, and index_policy ('write_optimized', 'balanced', 'scan_optimized', 'append_only'):

from sochdb import Database

# Optimize for write throughput
db = Database.open("./my_first_db", config={
"sync_mode": "normal",
"group_commit": True,
"index_policy": "write_optimized",
})

Next Steps

GoalResource
Build a complete appFirst App Tutorial
Learn vector searchVector Search Tutorial
Use with LLM agentsMCP Integration
Understand internalsArchitecture
ContributeContributing Guide

Troubleshooting

Common Issues

Python: ModuleNotFoundError: No module named 'sochdb'

pip install --upgrade sochdb

Rust: error: linking with 'cc' failed

Install build tools:

# macOS
xcode-select --install

# Ubuntu/Debian
sudo apt install build-essential

# Fedora
sudo dnf install gcc

Permission denied on Unix socket

The IPC server listens on a sochdb.sock socket inside the database directory. Unix sockets are not available on Windows. Fix permissions with:

chmod 755 ./my_first_db/sochdb.sock

Get Help