Metadata-Version: 2.4
Name: xeze-dbr-core
Version: 0.1.1
Summary: Official unified database wrapper for the Xeze infrastructure.
Author-email: Xeze <dev@xeze.org>
License: Apache-2.0
Project-URL: Homepage, https://code.xeze.org/xeze/xeze-dbr-core
Project-URL: Repository, https://code.xeze.org/xeze/xeze-dbr-core
Project-URL: Bug Tracker, https://code.xeze.org/xeze/xeze-dbr-core/issues
Keywords: xeze,database,grpc,postgres,mongodb,redis,vault
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: hvac>=1.1.0
Requires-Dist: grpcio>=1.50.0
Requires-Dist: protobuf>=4.21.0
Requires-Dist: xeze-dbr
Dynamic: requires-python

# xeze-dbr-core

Official unified database wrapper for the Xeze infrastructure. Provides a single, heavily-abstracted client for **PostgreSQL**, **MongoDB**, and **Redis** over mTLS via HashiCorp Vault.

## Installation

```bash
pip install git+https://code.xeze.org/xeze/xeze-dbr-core.git
```

Or install locally for development:

```bash
pip install .
```

## Quick Start

```python
from xeze_core import XezeCoreClient

db = XezeCoreClient(app_namespace="xms")
db.init_workspace()  # Ensures the 'xms_pg' database exists

# Postgres
db.pg_insert("students", {"name": "Ayush", "grade": "A"})

# MongoDB
db.mongo_insert("audit_logs", {"action": "student_added", "timestamp": "2026-04-05"})

# Redis
db.redis_set("cache:student:latest", "Ayush", ttl=300)
```

## Environment Variables

| Variable           | Default                    | Description                |
| ------------------ | -------------------------- | -------------------------- |
| `VAULT_ADDR`       | `http://127.0.0.1:8200`   | HashiCorp Vault address    |
| `VAULT_TOKEN`      | `dev-root-token`           | Vault authentication token |
| `DB_ROUTER_HOST`   | `db.0.xeze.org:443`       | Database Router gRPC host  |

## Architecture

- **Database-per-Service isolation** — each `app_namespace` gets its own `{ns}_pg`, `{ns}_mongo`, and `{ns}:` Redis prefix.
- **Vault mTLS** — client certs are fetched from Vault KV at `dbrouter/certs` and loaded in-memory only.
- **gRPC/Protobuf abstraction** — all Protobuf packing is handled internally; developers work with native Python dicts.
