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.1.tar.gz
(7.1 kB
view details)
Built Distribution
File details
Details for the file mkdocs_sql-0.2.1.tar.gz
.
File metadata
- Download URL: mkdocs_sql-0.2.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f48187431323b4371f1b2e9af497d2f6586cdfd5f4290d2f3f079a80fe85e670 |
|
MD5 | 878e50b87c6d5ec815d7ef8d8909ad03 |
|
BLAKE2b-256 | 52a0bbdf773beec26afef855d0f1fbbed2be6ef21b0907f530539d646b0faa10 |
File details
Details for the file mkdocs_sql-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_sql-0.2.1-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 | c48610b0558752edeec63bbfaeb2a22334c9f3c488937ad059bb7930f3e286f9 |
|
MD5 | 7ed0f4fda5e48c99291fdde4d9f00912 |
|
BLAKE2b-256 | 34a857e36ccc7d963160cf28b4cd36574d9680d21bae8fe0e0aa5a9fb1cd80a8 |