A high-performance Python client for the NenDB graph database, built with Zig under the hood.
- High Performance: Built on top of NenDB's Zig-based HTTP server
- Python Native: Familiar Python API for graph operations
- Graph Algorithms: BFS, Dijkstra, PageRank, and more
- Type Safety: Full type hints and error handling
- Async Support: Both synchronous and asynchronous operations
┌─────────────────┐ HTTP/JSON ┌─────────────────┐
│ Python App │ ──────────────► │ NenDB Server │
│ │ │ (Zig + HTTP) │
│ nen-python- │ ◄────────────── │ │
│ driver │ │ │
└─────────────────┘ └─────────────────┘
The Python driver communicates with NenDB's HTTP server, which is built in Zig for maximum performance. This gives you the best of both worlds: Python's ease of use with Zig's performance.
pip install NenDBBefore using the Python driver, you need to have the NenDB server running. Here are the quickest ways to get started:
curl -fsSL https://github.com/Nen-Co/nen-db/releases/latest/download/nen-linux-x86_64.tar.gz | tar -xzInvoke-WebRequest -Uri "https://github.com/Nen-Co/nen-db/releases/latest/download/nen-windows-x86_64.zip" -OutFile "nen-windows.zip"
Expand-Archive -Path "nen-windows.zip" -DestinationPath "."# Pull and run with HTTP server on port 8080
docker run --rm -p 8080:8080 --name nendb \
-v $(pwd)/data:/data \
ghcr.io/nen-co/nendb:latestgit clone https://github.com/Nen-Co/nen-db.git
cd nen-db
zig build
./zig-out/bin/nendbcurl http://localhost:8080/health
# Should return: {"status": "healthy", "service": "nendb", "version": "0.0.1"}pip install NenDBfrom nen_python_driver import NenDBClient
# Connect to NenDB server
client = NenDBClient("http://localhost:8080")
# Check server health
health = client.health()
print(f"Server status: {health['status']}")
# Get graph statistics
stats = client.graph_stats()
print(f"Graph has {stats['nodes']} nodes and {stats['edges']} edges")
# Run BFS algorithm
result = client.bfs(start_node=0, max_depth=3)
print(f"BFS algorithm: {result['status']}")client = NenDBClient(
base_url="http://localhost:8080", # NenDB server URL
timeout=30, # Request timeout in seconds
retries=3 # Number of retries on failure
)# Check server health
health = client.health()
# Get graph statistics
stats = client.graph_stats()# Breadth-First Search
bfs_result = client.bfs(
start_node=0, # Starting node ID
max_depth=3, # Maximum search depth
filters={} # Optional node/edge filters
)
# Dijkstra Shortest Path
dijkstra_result = client.dijkstra(
start_node=0, # Starting node ID
end_node=5, # Target node ID
weight_property="cost" # Edge weight property
)
# PageRank
pagerank_result = client.pagerank(
iterations=100, # Number of iterations
damping_factor=0.85, # Damping factor
tolerance=1e-6 # Convergence tolerance
)from nen_python_driver import NenDBError
try:
result = client.bfs(start_node=0, max_depth=3)
except NenDBError as e:
print(f"Error: {e}")
if e.details:
print(f"Details: {e.details}")# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest tests/
# Run with coverage
pytest --cov=nen_python_driver tests/# Install documentation dependencies
pip install -r requirements-docs.txt
# Build docs
sphinx-build -b html docs/ docs/_build/htmlThe Python driver is designed for high performance:
- Connection Pooling: Reuses HTTP connections
- Request Batching: Batches multiple operations
- Async Support: Non-blocking operations
- Error Recovery: Automatic retries and fallbacks
- Fork the repository
- Create a feature branch
- Write tests for your changes
- Ensure all tests pass
- Submit a pull request
MIT License - see LICENSE file for details.
- Issues: GitHub Issues
- Documentation: docs.nen.co
- Community: Discord