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
- Add to mkdocs.yml:
plugins:
- sql:
databasePath:
type: sqlite
path: ./path/to/database.file
- 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.3.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file mkdocs_sql-0.2.3.tar.gz
.
File metadata
- Download URL: mkdocs_sql-0.2.3.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 668154b26ec5c1c0b4458342e2563327359a3b63ebb086537f6d440c436779b4 |
|
MD5 | 73402321ead003b6cef669ceeac07933 |
|
BLAKE2b-256 | 25adbf81a3855cc01fe8c125035b0c08d08446d0a473bdf88040973154803a18 |
File details
Details for the file mkdocs_sql-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_sql-0.2.3-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 794b8e6a7d0f3a0383bd7d3182cfd67e766a925477d992305e63cb93cfc3416e |
|
MD5 | 89df88ec125283b766ce2ccd0e848179 |
|
BLAKE2b-256 | e0903a7dcc8e5cb1a10a0ef5ba3f70affc52e65d432bd9283d2022c76357500e |