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.3.tar.gz (10.7 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.3-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: context_renderer-0.1.3.tar.gz
  • Upload date:
  • Size: 10.7 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.3.tar.gz
Algorithm Hash digest
SHA256 4a52d4d43c0f10533ea8ca58a2abb687cc8778c65b9a4a19188ebee067085196
MD5 a86ec5829688cc5d1fa40e9b73d39b1e
BLAKE2b-256 6cec5fc8c6e9e5b77ee5becb7bffe88dcfc6730e571b948ed91c61ed81b4b213

See more details on using hashes here.

File details

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

File metadata

  • Download URL: context_renderer-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e8d1ab8b763a25f7a4e5932950a602fe29941aaef18ed0d93bf1e08c89eec84b
MD5 c2c023141137bd7c299823f5d2819677
BLAKE2b-256 f4c2a616fcfaf8cae4d18d7438a7a8e03a62d7c12d86bb8d251009e4f1c1fcbd

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