A unified Python client library for accessing Orbit-RS multi-model database through all supported protocols.
-
Multi-Protocol Support: Access Orbit-RS through any supported protocol
- PostgreSQL (SQL) - Port 5432
- MySQL (SQL) - Port 3306
- CQL/Cassandra - Port 9042
- Redis/RESP - Port 6379
- Cypher/Bolt (Neo4j) - Port 7687
- AQL/ArangoDB - Port 8529
- MCP (Model Context Protocol) - Port 8080
-
Unified API: Single client interface for all protocols
-
Type Safety: Full type hints and Pydantic models
-
Context Managers: Automatic connection management
-
Protocol-Specific Methods: Convenience methods for each protocol
pip install orbit-python-clientFor async support:
pip install orbit-python-client[async]For development:
pip install orbit-python-client[dev]from orbit_client import OrbitClient
# Connect to PostgreSQL
client = OrbitClient.postgres(
host="127.0.0.1",
port=5432,
username="orbit",
password="",
database="postgres"
)
# Execute SQL query
results = client.execute("SELECT * FROM users WHERE age > %s", params=(18,))
for row in results:
print(row)
# Context manager (automatic connection handling)
with OrbitClient.postgres() as client:
results = client.execute("SELECT id, name FROM users")
print(results)from orbit_client import OrbitClient
client = OrbitClient.mysql(
host="127.0.0.1",
port=3306,
database="orbit"
)
results = client.execute("SELECT * FROM products WHERE price > %s", params=(100,))from orbit_client import OrbitClient
client = OrbitClient.redis(host="127.0.0.1", port=6379)
# Using convenience methods
client.set("user:1", "John Doe", ex=3600) # Set with expiration
value = client.get("user:1")
client.delete("user:1")
# Using execute for any Redis command
client.execute("SET", args=("key", "value"))
client.execute("GET", args=("key",))
client.execute("HSET", args=("user:1", "name", "John", "age", "30"))from orbit_client import OrbitClient
client = OrbitClient.cql(
host="127.0.0.1",
port=9042,
keyspace="my_keyspace"
)
results = client.execute(
"SELECT * FROM users WHERE user_id = %s",
params=("123",)
)from orbit_client import OrbitClient
client = OrbitClient.cypher(
host="127.0.0.1",
port=7687,
database="neo4j"
)
# Create nodes
client.execute(
"CREATE (n:Person {name: $name, age: $age})",
params={"name": "Alice", "age": 30}
)
# Query nodes
results = client.execute(
"MATCH (n:Person) WHERE n.age > $age RETURN n",
params={"age": 25}
)from orbit_client import OrbitClient
client = OrbitClient.aql(
host="127.0.0.1",
port=8529,
database="_system"
)
results = client.execute(
"FOR doc IN users FILTER doc.age > @age RETURN doc",
bind_vars={"age": 18}
)from orbit_client import OrbitClient
client = OrbitClient.mcp(
host="127.0.0.1",
port=8080
)
# Execute natural language query
result = client.execute(
"tools/call",
params={
"name": "query_data",
"arguments": {
"query": "Show me all users from California"
}
}
)from orbit_client import OrbitClient
client = OrbitClient.postgres()
# Manual connection management
client.connect()
try:
results = client.execute("SELECT * FROM users")
finally:
client.disconnect()
# Using context manager (recommended)
with OrbitClient.postgres() as client:
results = client.execute("SELECT * FROM users")
# Connection automatically closed on exitfrom orbit_client import OrbitClient
client = OrbitClient.postgres()
# PostgreSQL batch insert
with client._protocol_client._connection.cursor() as cursor:
cursor.executemany(
"INSERT INTO users (name, email) VALUES (%s, %s)",
[("Alice", "alice@example.com"), ("Bob", "bob@example.com")]
)
client._protocol_client._connection.commit()from orbit_client import OrbitClient
import psycopg2
try:
client = OrbitClient.postgres()
results = client.execute("SELECT * FROM users")
except psycopg2.Error as e:
print(f"Database error: {e}")
except Exception as e:
print(f"Error: {e}")
finally:
client.disconnect()- Full SQL support (DDL, DML, DCL, TCL)
- Parameterized queries
- Transaction support
- Connection pooling (via underlying drivers)
- All Redis commands supported
- Convenience methods:
get(),set(),delete(),keys() - Pub/Sub support (via underlying redis-py)
- Pipeline support
- CQL 3.x support
- Prepared statements
- Batch operations
- Keyspace management
- Full Cypher query language
- Transaction support
- Parameterized queries
- Graph operations
- AQL query language
- Document operations
- Graph traversal
- Bind variables
- Natural language queries
- Schema discovery
- Tool execution
- Resource access
See the examples/ directory for complete examples:
examples/postgres_example.py- PostgreSQL usageexamples/redis_example.py- Redis usageexamples/cypher_example.py- Cypher/Bolt usageexamples/multi_protocol_example.py- Using multiple protocols
- Python 3.8+
- Protocol-specific drivers (automatically installed):
psycopg2-binaryfor PostgreSQLPyMySQLfor MySQLcassandra-driverfor CQLredisfor Redisneo4jfor Cypher/Boltpython-arangofor AQLhttpxfor MCP
BSD-3-Clause