Generate structured Markdown context sheets from MSSQL databases
Project description
context-renderer
Generate structured Markdown context sheets from your MSSQL databases — in one command.
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.
What it generates
output/MyDatabase/
├── 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
└── ...
Example — 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`
Example — 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 | — |
Quickstart
Requirements
- Docker & Docker Compose
- A reachable SQL Server instance (2016+)
1. Clone
git clone https://github.com/your-username/context-renderer.git
cd context-renderer
2. Start Jupyter
docker compose up --build
3. Run the notebook
Open notebooks/01_generate_context_sheets.ipynb, fill in your connection:
connector = MSSQLConnector(
host="your-server",
database="your-database",
username="sa",
password="your-password",
)
Run all cells → sheets are saved to notebooks/output/{database}/.
Package API
You can also use the context_renderer package directly:
from context_renderer import MSSQLConnector, DatabaseInspector, DataMetrics, ContextSheetRenderer
# 1. Connect
connector = MSSQLConnector(host="...", database="...", username="...", 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")
Project Structure
context-renderer/
├── docker-compose.yml
├── docker/
│ ├── Dockerfile
│ └── requirements.txt
├── notebooks/
│ ├── 01_generate_context_sheets.ipynb
│ └── output/ ← generated sheets (git-ignored)
├── context_renderer/ ← Python package
│ ├── __init__.py
│ ├── connector.py ← MSSQL connection (SQLAlchemy + pyodbc)
│ ├── inspector.py ← Schema metadata (tables, columns, PKs, FKs, indexes)
│ ├── metrics.py ← Data statistics (null rate, cardinality, top values)
│ └── renderer.py ← Markdown context sheet renderer
├── pyproject.toml
├── .gitignore
└── LICENSE
Roadmap
- PostgreSQL & MySQL connectors
- API source support (REST → context sheet)
- LLM-powered natural language table summaries
- CLI interface (
context-renderer run --host ... --db ...) - HTML output format
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file context_renderer-0.1.0.tar.gz.
File metadata
- Download URL: context_renderer-0.1.0.tar.gz
- Upload date:
- Size: 14.3 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5de15152a37dfec7047d3a0323df989b1ed1637a7dcc2b9985cfb5fd1b822db
|
|
| MD5 |
dc78abeea9c9f001b8e5c1f0267b9ca1
|
|
| BLAKE2b-256 |
310300e88bcb85c6e1e3339b067b7c6593440c23e2ab9045bbb700d14c15a43c
|
File details
Details for the file context_renderer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: context_renderer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.4 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c9176bdce5eb3406c78c95b62f5294248624e1bf5c4ea4103ce89bba0e67ec3
|
|
| MD5 |
4d29d240947571d988f741c55b3bd6e8
|
|
| BLAKE2b-256 |
4e8119532af50bf67e6f33ea8268b2ad113e91987cf3c9a4ef67ee86e97d091d
|