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.4.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file mkdocs_sql-0.2.4.tar.gz
.
File metadata
- Download URL: mkdocs_sql-0.2.4.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 | 16057685fca97ca8c270687e52db50158495e0dc4f863f4897f43c75a8f0fbc4 |
|
MD5 | aa7ba38db1d0369477b2cfbef8af6a7e |
|
BLAKE2b-256 | 61a344b427f4d0401324fff517c200db39ca9ab0837e6938bc77d5b16388e99a |
File details
Details for the file mkdocs_sql-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_sql-0.2.4-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 | 2e74d132931c551d4628593d4832db3560f535b174218559bb97994a26604ba2 |
|
MD5 | 09269302f5dd74a8cfdb8184265c499a |
|
BLAKE2b-256 | 683936662496c2def5d6df4538564d95b27917955b76e63a9be843476b8f66ea |