Skip to main content

AI-native database seatbelt that blocks destructive SQL, tracks latency, and ships Gemini-powered remediation guidance.

Project description

gudb: The Database Seatbelt 🛡️

gudb is a high-performance database safety layer designed to prevent production disasters before they happen. It acts as a "seatbelt" for your data, intercepting dangerous queries at the driver level with zero-latency heuristics and Senior DRE-level AI advice.

✨ Why a Seatbelt?

  • Zero-Latency Protection: Local heuristics block DELETE or DROP without WHERE in <1ms.
  • Fail-Safe by Design: If the AI or network is down, the seatbelt stays on.
  • AI Advisor: Deep query analysis and optimization tips provided by Gemini AI.
  • Driver-Level Hook: Drops into your psycopg2 connection in one line of code.
  • Privacy First: SQL redaction ensures sensitive PII never leaves your network.

📦 Installation

pip install gudb

To install with framework-specific extras:

pip install "gudb[fastapi]"

🚀 Quick Start

1. The One-Liner (DB Driver Level)

Wrap your database connection to start guarding immediately.

import psycopg2
from gudb import monitor

# Create your connection
raw_conn = psycopg2.connect("postgres://...")

# --- GUARD IT ---
conn = monitor(raw_conn)
# -----------------

cur = conn.cursor()
cur.execute("DELETE FROM orders;") # 🛑 Raises DisasterBlockedError

2. FastAPI Integration

from fastapi import FastAPI
from gudb.middlewares.fastapi import SafeDBMiddleware

app = FastAPI()
app.add_middleware(SafeDBMiddleware)

⚙️ Configuration

The SDK can be configured via environment variables:

Variable Description Default
GUDB_API_ENDPOINT The evaluation backend URL https://ai-db-sentinel.onrender.com/api/sdk/evaluate
GUDB_ENVIRONMENT prod, stage, or dev production
GUDB_FAIL_OPEN Allow queries if AI is down True
GUDB_REDACT_PII Scrub SQL literals True

🛠️ Advanced Usage (Extensibility)

You can implement your own AI provider if you want to use a local model or a different API.

from gudb.providers.base import BaseProvider
from gudb import Gudb

class MyCustomProvider(BaseProvider):
    def evaluate(self, query, context):
        if "DROP" in query.upper():
            return {"verdict": "STOP", "issue": "No drops allowed"}
        return {"verdict": "GO"}

# Initialize with custom provider
gudb = Gudb(provider=MyCustomProvider())

🏗️ Development & Publishing

To test locally:

pip install -e .[dev]
pytest tests/

To publish to PyPI:

python -m build
twine upload dist/*

Built with ❤️ by the gudb Team. Ensuring your database sleeps soundly.

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

gudb-0.2.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

gudb-0.2.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gudb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 49ed03ec1521de1e7311752110b9ca8f347756a71ca834b5a7470c47334a9f9a
MD5 dede9497207ab42a7f4f7ef9814b60d8
BLAKE2b-256 b9b0bd54c73a0353ff1931dd98422269824dba9e1671ec2c24306a075c5b7141

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gudb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edf2a0cf98ffecb6fa263c7f31368d1e0eb5e5b231a01eaaae32d7ddc4e3b000
MD5 672d3e43fc2208e0f5333e02d7c0b966
BLAKE2b-256 acea3eeff5ffc5a2b71d988a75cfa792dab6a56a4e420b01962614be689370e7

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