Integration Guides
Connect NenDB to your favorite languages, frameworks, and tools with official drivers and community libraries.
Official Language Drivers
Py
Python Driver
Full-featured Python client with async support and connection pooling.
Installation
pip install nendb-python
Basic Usage
import nendb
# Connect to NenDB
client = nendb.Client("tcp://localhost:3000")
# Insert data
result = client.batch_insert([
{"id": 1, "name": "Alice", "age": 30},
{"id": 2, "name": "Bob", "age": 25}
])
# Query data
users = client.query("MATCH (u:User) RETURN u")
print(users)JS
JavaScript/Node.js Driver
Modern JavaScript client with TypeScript support and WebSocket connectivity.
Installation
npm install @nendb/client
Basic Usage
import { NenClient } from '@nendb/client';
// Connect to NenDB
const client = new NenClient('tcp://localhost:3000');
// Insert data
const result = await client.batchInsert([
{ id: 1, name: 'Alice', age: 30 },
{ id: 2, name: 'Bob', age: 25 }
]);
// Query data
const users = await client.query('MATCH (u:User) RETURN u');
console.log(users);Go
Go Driver
High-performance Go client optimized for concurrent operations.
Installation
go get github.com/nen-co/nendb-go
Basic Usage
package main
import (
"github.com/nen-co/nendb-go"
"fmt"
)
func main() {
client, err := nendb.Connect("tcp://localhost:3000")
if err != nil {
panic(err)
}
defer client.Close()
// Insert data
result, err := client.BatchInsert([]map[string]interface{}{
{"id": 1, "name": "Alice", "age": 30},
{"id": 2, "name": "Bob", "age": 25},
})
// Query data
users, err := client.Query("MATCH (u:User) RETURN u")
fmt.Println(users)
}Rs
Rust Driver
Memory-safe Rust client with zero-cost abstractions and async/await support.
Installation
[dependencies] nendb-client = "0.2.0"
Basic Usage
use nendb_client::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect("tcp://localhost:3000").await?;
// Insert data
let result = client.batch_insert(vec![
serde_json::json!({"id": 1, "name": "Alice", "age": 30}),
serde_json::json!({"id": 2, "name": "Bob", "age": 25}),
]).await?;
// Query data
let users = client.query("MATCH (u:User) RETURN u").await?;
println!("{:?}", users);
Ok(())
}Framework Integrations
⚛️
React + Next.js
Real-time React hooks and Next.js API routes for seamless frontend integration.
// hooks/useNenDB.js
import { useQuery, useMutation } from '@nendb/react';
export function useUsers() {
const { data, loading, error } = useQuery('MATCH (u:User) RETURN u');
const [createUser] = useMutation({
query: 'CREATE (u:User) SET u = $props RETURN u',
onCompleted: (data) => {
console.log('User created:', data);
}
});
return { users: data, loading, error, createUser };
}🌶️
FastAPI + Python
High-performance REST API with automatic OpenAPI documentation.
from fastapi import FastAPI, HTTPException
from nendb import Client
app = FastAPI()
client = Client("tcp://localhost:3000")
@app.get("/users")
async def get_users():
try:
users = await client.query("MATCH (u:User) RETURN u")
return {"users": users}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))Connection Configuration
Connection String Formats
TCP Connection
tcp://localhost:3000
tcp://username:password@localhost:3000/database
Secure TCP with TLS
tcps://localhost:3001
Connection Pool Configuration
const client = new NenClient('tcp://localhost:3000', {
pool: {
min: 5, // Minimum connections
max: 20, // Maximum connections
acquireTimeout: 30000, // Connection acquire timeout
idleTimeout: 300000, // Idle connection timeout
},
reconnect: {
enabled: true,
maxRetries: 10,
backoff: 'exponential'
}
});Best Practices
⚡ Performance Tips
- • Use batch operations for multiple inserts/updates
- • Enable connection pooling for high-traffic applications
- • Cache frequently accessed data using nen-cache
- • Use prepared statements for repeated queries
- • Monitor connection pool usage and adjust pool size accordingly
🛡️ Security Considerations
- • Always use parameterized queries to prevent injection attacks
- • Enable TLS for production deployments
- • Use strong authentication credentials
- • Implement proper error handling to avoid data leaks
- • Regularly update client drivers to latest versions