This directory contains practical examples demonstrating SochDB Python SDK usage across various scenarios.
# Install the SDK
cd sochdb-python-sdk
pip install -e .
# Build the native library (for embedded mode)
cd ..
cargo build --release| Example | Mode | Description |
|---|---|---|
01_basic_operations.py |
Embedded | Basic CRUD operations |
02_transactions.py |
Embedded | Transaction handling and rollback |
03_path_navigation.py |
Embedded | Hierarchical path-based data access |
04_scan_and_range.py |
Embedded | Range scans and batch operations |
05_user_store.py |
Embedded | Real-world user management example |
06_json_documents.py |
Embedded | Storing and querying JSON documents |
07_session_cache.py |
Embedded | Session caching use case |
08_ipc_client.py |
IPC | Multi-process access via IPC |
# Set the library path
export SOCHDB_LIB_PATH=/path/to/toon_database/target/release
# Run any example
python examples/01_basic_operations.pyRequires a running SochDB IPC server:
# Start the server first (from sochdb-storage)
cargo run --bin ipc_server -- --socket /tmp/sochdb.sock
# Then run the example
python examples/08_ipc_client.pyexamples/
├── README.md # This file
├── 01_basic_operations.py # Simple key-value CRUD
├── 02_transactions.py # ACID transaction examples
├── 03_path_navigation.py # Path-native API examples
├── 04_scan_and_range.py # Range queries
├── 05_user_store.py # User management use case
├── 06_json_documents.py # JSON document storage
├── 07_session_cache.py # Session caching pattern
├── 08_ipc_client.py # IPC client examples
└── shared/
└── mock_server.py # Mock server for testing
The simplest example to get started:
from sochdb import Database
# Open/create a database
db = Database.open("./my_data")
# Store data
db.put(b"greeting", b"Hello, SochDB!")
# Retrieve data
value = db.get(b"greeting")
print(value) # b"Hello, SochDB!"
# Clean up
db.close()- Key-Value Cache: Examples 1, 7
- User/Entity Management: Example 5
- Document Storage: Example 6
- Multi-process Access: Example 8
- Batch Operations: Example 4
- Hierarchical Data: Example 3