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.4.tar.gz (11.0 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.4-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: context_renderer-0.1.4.tar.gz
  • Upload date:
  • Size: 11.0 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.4.tar.gz
Algorithm Hash digest
SHA256 c85b9254f25e2d4ce8643b2e321a7a6e1d5c7e7681cbfb9eafebbedc653d2799
MD5 5a6deaec2035f1202e587fc3797e0300
BLAKE2b-256 e5097c6d1941eaffc2177afbe13e68dc2601a8003392d6df3d578debc0d50659

See more details on using hashes here.

File details

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

File metadata

  • Download URL: context_renderer-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 13.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 87adc5b297ff22af613236d59bb3d833ff8a5d382b6de9c447f095b00af9964a
MD5 7d1906e4ec966f701df9d703497d3983
BLAKE2b-256 32e914ca4abf7ccec11f66d84077761e707c92c9e42c3eaae4617b59d86f0b12

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