Skip to main content

Python gRPC client for the Xeze Database Router (PostgreSQL, MongoDB, Redis over mTLS)

Project description

xeze-dbr

Python gRPC client for the Xeze Database Router — a unified interface for PostgreSQL, MongoDB, and Redis over mTLS.

Install

pip install xeze-dbr

Quick Start

from xeze_dbr import connect

# Connect with mTLS (production)
client = connect(
    host="db.0.xeze.org:443",
    cert_path="client.crt",
    key_path="client.key",
)

# Health check
health = client.health.Check(client.pb2.HealthCheckRequest())
print(health.overall_healthy)  # True

# PostgreSQL — list databases
dbs = client.postgres.ListDatabases(client.pb2.ListDatabasesRequest())
print(dbs.databases)

# PostgreSQL — insert data
from google.protobuf import struct_pb2
resp = client.postgres.InsertData(client.pb2.InsertDataRequest(
    database="mydb",
    table="users",
    data={
        "name": struct_pb2.Value(string_value="Alice"),
        "age": struct_pb2.Value(number_value=28),
    }
))
print(resp.inserted_id)

# MongoDB — insert document
doc = struct_pb2.Struct()
doc.update({"event": "signup", "user": "Alice"})
resp = client.mongo.InsertDocument(client.pb2.InsertDocumentRequest(
    database="mydb",
    collection="events",
    document=doc,
))
print(resp.inserted_id)

# Redis — set & get
client.redis.SetValue(client.pb2.SetValueRequest(
    key="session:abc", value="user:42", ttl=3600
))
val = client.redis.GetValue(client.pb2.GetValueRequest(key="session:abc"))
print(val.value)

# Clean up
client.close()

Vault / Secret Manager Integration (No Files)

If you use HashiCorp Vault, AWS Secrets Manager, or Doppler, you can pass raw certificate bytes instead of file paths using cert_data and key_data parameters:

import hvac
from xeze_dbr import connect

# 1. Get raw bytes from Vault
vault = hvac.Client(url="http://127.0.0.1:8200", token="dev-root-token")
secret = vault.secrets.kv.v2.read_secret_version(path="dbrouter/certs")

# 2. Connect directly (no files on disk!)
client = connect(
    host="db.0.xeze.org:443",
    cert_data=secret["data"]["data"]["client_cert"].encode(),
    key_data=secret["data"]["data"]["client_key"].encode(),
)

Local Development (no TLS)

client = connect(host="localhost:50051", insecure=True)

Available Services

Stub Methods
client.health Check, CheckPostgres, CheckMongo, CheckRedis
client.postgres ListDatabases, CreateDatabase, ListTables, ExecuteQuery, SelectData, InsertData, UpdateData, DeleteData
client.mongo ListDatabases, ListCollections, InsertDocument, FindDocuments, UpdateDocument, DeleteDocument
client.redis ListKeys, SetValue, GetValue, DeleteKey, Info

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xeze_dbr-0.2.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xeze_dbr-0.2.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file xeze_dbr-0.2.1.tar.gz.

File metadata

  • Download URL: xeze_dbr-0.2.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for xeze_dbr-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5e9b197304c1fdfce7000c9fa1acb33e6b34d79572cfe185579e627ecfdf728c
MD5 d52db73020a51313eeea81b9d4fd735f
BLAKE2b-256 347e99771d35b53711af0dbd7ef28eae459975ffb714c0919129c63d2491948a

See more details on using hashes here.

File details

Details for the file xeze_dbr-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: xeze_dbr-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for xeze_dbr-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9985eaf294bc3ebabf248fc168bb28c1e8a6cf3205813909f2264bf19414b858
MD5 f1ba234d0551f3751cc5ea0ba8a25cb9
BLAKE2b-256 1bf4516f9173aa6089a4ee3aa1f2ab2ad867e5fac087dfd04a8f881516c5e1cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page