Skip to main content

Service-first database intelligence platform for safe inspection and agent-ready exports

Project description

sqldbagent

CI PyPI Docs Python 3.13 PDM License: MIT

Safe database intelligence for agents, operators, and automation.

sqldbagent is a service-first platform for understanding relational databases through normalized metadata, durable artifacts, guarded querying, and agent-ready surfaces. It starts with Postgres and MSSQL, uses SQLite as a lightweight smoke/E2E target, and keeps the shared service layer authoritative across every interface.

Why This Exists

Most database tooling gives you one of two extremes:

  • a thin SQL shell with no meaningful safety boundary
  • a one-off schema export with no reusable runtime context

sqldbagent is trying to sit in the middle:

  • inspect and normalize database structure once
  • store snapshots, profiles, docs, diagrams, prompts, and retrieval indexes durably
  • let CLI workflows, dashboards, MCP tools, and LangGraph agents reuse that context
  • keep all agent-facing SQL behind an explicit read-only safety layer

Core Shape

The architecture rule is:

Normalized Metadata Core In The Middle, Dialect Enrichers On The Edges

That means:

  • shared models for databases, schemas, tables, views, columns, relationships, profiles, and snapshots
  • Postgres and MSSQL adapters for dialect-specific introspection and execution details
  • thin surfaces on top: CLI, dashboard, MCP, LangChain, and LangGraph

Current Capabilities

  • datasource config and engine factories through Pydantic Settings and .env
  • normalized inspection of servers, schemas, tables, and views
  • profiling with row counts, distinct/null stats, samples, storage hints, and entity heuristics
  • guarded sync and async SQL execution
  • snapshot persistence with per-datasource and per-schema storage
  • snapshot diffing, docs export, Mermaid ER export, and prompt export
  • Qdrant-backed retrieval over stored snapshot documents
  • LangChain tools and LangGraph agent builders with middleware, checkpointing, and optional LangSmith tracing
  • FastMCP server surface
  • Streamlit dashboard chat surface over the same persisted agent stack

Install

With PDM:

pdm install -G :all

With pip:

pip install "sqldbagent[cli,postgres,langchain,langgraph,mcp,dashboard,docs,test]"

Local Demo

Bring up the local integration stack and migrate the demo database:

make up
make demo-migrate

Run the common workflow:

pdm run sqldbagent inspect tables postgres_demo --schema public
pdm run sqldbagent snapshot create postgres_demo public
pdm run sqldbagent prompt export postgres_demo public
make dashboard-demo

Agent Stack

sqldbagent uses LangChain v1's create_agent(...) surface on top of LangGraph runtime primitives.

  • state is seeded from stored snapshots
  • middleware owns prompt injection, tool handling, summarization, HITL, and limits
  • Postgres checkpointing is the durable thread path
  • the dashboard uses a session-scoped memory saver when Postgres checkpointing is not enabled
  • LangSmith tracing is optional and .env-driven

langgraph.json points at the local project root and .env, so langgraph dev uses the same package and tracing configuration as the rest of the repo.

Documentation

Public docs live at sqldbagent.readthedocs.io, internal repo memory lives in docs/_internal, and the main contributor rules live in AGENTS.md.

Useful entrypoints:

Build docs locally:

make docs
make docs-live

Development

trunk check --fix
make test
make test-integration
make test-e2e

Publishing

make build
make publish-check
make publish-testpypi
make publish-pypi

The repo also includes GitHub Actions workflows for CI, docs builds, and trusted-publisher PyPI releases on version tags.

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

sqldbagent-0.1.1.tar.gz (91.6 kB view details)

Uploaded Source

Built Distribution

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

sqldbagent-0.1.1-py3-none-any.whl (99.2 kB view details)

Uploaded Python 3

File details

Details for the file sqldbagent-0.1.1.tar.gz.

File metadata

  • Download URL: sqldbagent-0.1.1.tar.gz
  • Upload date:
  • Size: 91.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sqldbagent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 366b0c5255538bbeb22cf7d680d60ffffc5f602626d66ff1e21ef6c9b77dfd34
MD5 9a7000430bf18504608340f95bc52699
BLAKE2b-256 803bb77eda196cd9ef7fbe58c52e6d064d0decf2f53a778cff63a9a5247fb6ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqldbagent-0.1.1.tar.gz:

Publisher: publish.yml on pr1m8/sqldbagent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqldbagent-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sqldbagent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 99.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sqldbagent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af2b8adfacdfcd53c00fd6a2bbc1c609c9ed30dc9fd0c5eec3b31c682886e748
MD5 51bbb75cb9909807fc5f470e8badac0d
BLAKE2b-256 56192cd756d68489b16e13ecf1969df5d112a9f92e9747ce5d65cc3d7a3e8e33

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqldbagent-0.1.1-py3-none-any.whl:

Publisher: publish.yml on pr1m8/sqldbagent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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