Skip to main content

Generate structured Markdown context sheets from MSSQL databases

Project description

context-renderer

Generate structured Markdown context sheets from your MSSQL databases — in one command.

PyPI Python License: MIT

context-renderer connects to a Microsoft SQL Server database, inspects its full structure, computes data metrics, and produces clean Markdown context sheets — one overview + one detailed file per table.

Perfect for onboarding, documentation, LLM context injection, or just understanding an unfamiliar database.


Installation

pip install context-renderer

Prerequisite: ODBC Driver 18 for SQL Server must be installed on the host machine.


Usage

from context_renderer import MSSQLConnector, DatabaseInspector, DataMetrics, ContextSheetRenderer

# 1. Connect
connector = MSSQLConnector(host="your-server", database="your-db", username="sa", password="...")
engine = connector.get_engine()

# 2. Inspect schema
schema = DatabaseInspector(engine).inspect()

# 3. Compute data metrics (optional — skip for speed)
metrics = DataMetrics(engine).compute_all(schema.tables)

# 4. Save context sheets
ContextSheetRenderer(schema, metrics).save("./output")

Output structure

output/your-db/
├── 00_database_overview.md     ← Summary, table list, FK relation map, routines
├── dbo__Users.md               ← Columns, PKs, FKs, indexes, null %, cardinality, top values
├── dbo__Orders.md
└── ...

What the sheets look like

00_database_overview.md

# Database Overview — `MyDatabase`

## Summary
| Property | Value          |
|----------|----------------|
| Schemas  | `dbo`, `audit` |
| Tables   | 12             |
| Views    | 3              |

## Foreign Key Relations
- `dbo.Orders.user_id``dbo.Users.id`
- `dbo.OrderItems.order_id``dbo.Orders.id`

dbo__Orders.md

# `dbo`.`Orders`
> Row count: 1,482,309

## Columns
| # | Column   | Type          | Nullable | PK | Null % | Distinct | Top Values        |
|---|----------|---------------|----------|----|--------|----------|-------------------|
| 1 | `id`     | `int`         | ✗        | 🔑 | 0.0%   | 1482309  | —                 |
| 2 | `status` | `varchar(20)` | ✗        |    | 0.0%   | 4        | `pending`, `paid` |
| 3 | `amount` | `decimal`     | ✓        |    | 2.1%   | 18402    | —                 |

Full project & Jupyter notebook

For a Docker-based Jupyter workflow (no local ODBC setup required), see the project repository.


License

MIT — see LICENSE.

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

context_renderer-0.1.5.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

context_renderer-0.1.5-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file context_renderer-0.1.5.tar.gz.

File metadata

  • Download URL: context_renderer-0.1.5.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_renderer-0.1.5.tar.gz
Algorithm Hash digest
SHA256 205541a5beb4b167cea85825843f313e36e73d48770a994f67e0d15e9614bc8a
MD5 1ae06ae3617b2eda138977ea3886d16b
BLAKE2b-256 0e1acc97e1599792e364b01d69f8154e2a67c398a61c0700de2a3c628909ce4b

See more details on using hashes here.

File details

Details for the file context_renderer-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: context_renderer-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_renderer-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 beb060209c4704b3319b942c0906e60d22a569765dfaa31e304b2c5ad0dd51f6
MD5 6f75d7c930bf61c7e54bc130bc4682e0
BLAKE2b-256 33913a1429e2ecf0e65214611b9a04e40d8a238ac2faf5e8c7838b3aaeceb053

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