Skip to main content

A MkDocs plugin for executing and displaying SQL queries

Project description

mkdocs-sql

A MkDocs plugin for executing and embedding output of SQL queries in your documentation.

Features

  • Embed output of SQL queries in your markdown files
  • Support for SQLite databases
  • Display results as formatted tables
  • Error handling and display
  • Database configuration via mkdocs.yml
  • Live updates - changes to database reflect immediately in documentation
  • Toggle SQL queries on/off
  • Toggle between formatted and raw markdown views

Installation

pip install mkdocs-sql

Usage

  1. Add to mkdocs.yml:
plugins:
  - sql:
      databasePath:
        type: sqlite
        path: ./path/to/database.file
  1. In your markdown files:
---
databasePath: ./relative/path/to/database.file
showQuery: true  # optional, defaults to true
---

```sql
SELECT * FROM users LIMIT 5;

## Example Database Management

The plugin comes with a sample population database and management script. You can use it to test live updates:

```bash
# Reset database to initial state
python docs/examples/create_sample_db.py --reset

# Update a city's population (±10% random change)
python docs/examples/create_sample_db.py --update-city "New York"

# Update a country's population (±5% random change)
python docs/examples/create_sample_db.py --update-country "United States"

Changes to the database are reflected immediately in the documentation - just refresh the page!

Configuration

Option Description Default
databasePath.type Database type (currently only sqlite) sqlite
databasePath.path Path to database file None
showQuery Show SQL queries by default true

License

MIT

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

mkdocs_sql-0.2.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

mkdocs_sql-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_sql-0.2.0.tar.gz.

File metadata

  • Download URL: mkdocs_sql-0.2.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for mkdocs_sql-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ed2ca60d38ff0b7ef9d2f3b300299492ee26e8702f89f88828f57858187e6ff0
MD5 572194c07cea5721ea3d9d3cfe88554e
BLAKE2b-256 0f785c6b9d42df568aef3e40d0491f9d2bb760ea508ee81ae5259d7ebc7849cc

See more details on using hashes here.

File details

Details for the file mkdocs_sql-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_sql-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for mkdocs_sql-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8f416a01962e92815f9979e2cf5ad12f90b27205603ca12e773e86855f183ad
MD5 8380d7e5b7ace8587ab2f80736fdcde3
BLAKE2b-256 19186f9bdc8522fe043451816ce546efa6bce9056aa79c89daddcff8405ae7b0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page