A MkDocs plugin for executing and displaying SQL queries
Project description
mkdocs-sql
A MkDocs plugin for executing and displaying SQL queries directly in your documentation. Create beautiful, interactive documentation with live SQL queries and formatted results.
Features
-
Live SQL Query Execution
- Execute SQL queries directly in your markdown files
- Support for SQLite and DuckDB databases
- Automatic error handling and display
-
Beautiful Table Formatting
- Smart column type detection
- Proper alignment (right for numbers, left for text)
- Formatted numbers with commas (1,234,567)
- Clean, modern table styling
- Alternating row colors and hover effects
-
Interactive Controls
- Toggle between formatted and raw markdown tables
- Show/hide SQL queries
- State persistence for query visibility
- Material Design icons
-
Flexible Configuration
- Global database settings in mkdocs.yml
- Per-page database override in frontmatter
- Support for relative and absolute paths
- Home directory expansion (~)
Installation
pip install mkdocs-sql
Quick Start
- Add to your mkdocs.yml:
plugins:
- sql:
database:
type: sqlite # or duckdb
path: ./path/to/database.file
- Add Material Icons to mkdocs.yml:
extra_css:
- https://fonts.googleapis.com/icon?family=Material+Icons
- In your markdown files:
```sql
SELECT name, population, gdp_usd
FROM countries
ORDER BY population DESC
LIMIT 5;
## Configuration
### Global Configuration (mkdocs.yml)
```yaml
plugins:
- sql:
database:
type: sqlite # or duckdb
path: ./path/to/database.file
show_query: true # default: false
Per-page Configuration (Markdown Frontmatter)
---
database: ./different/database.sqlite
show_query: true
---
Configuration Options
Option | Description | Default |
---|---|---|
database.type | Database type (sqlite/duckdb) | sqlite |
database.path | Path to database file | None |
show_query | Show SQL queries by default | false |
Examples
Check out our example documentation for:
- Population data analysis
- Database schema documentation
- Complex query examples
- Table formatting examples
Features in Detail
Smart Column Formatting
- Population numbers: Formatted with commas (1,234,567)
- Percentages: 2 decimal places
- Currency: Proper decimal alignment
- Automatic detection of numeric columns
Interactive Controls
- Table Toggle: Switch between formatted and raw markdown
- Query Toggle: Show/hide SQL queries
- Persistent query visibility state
- Clean, minimal interface
Table Styling
- Proper column alignment
- Alternating row colors
- Hover effects
- Responsive design
- Clean borders and spacing
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Support
If you encounter any issues or have questions, please open an issue.
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
File details
Details for the file mkdocs_sql-0.1.0.tar.gz
.
File metadata
- Download URL: mkdocs_sql-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58463b222047a16ff7042af11a8bb800cba921bd6d66f30a1255f2ed52387d6f |
|
MD5 | 45fc02a27f91d335926bbacfec465fdc |
|
BLAKE2b-256 | 1fd90cf651345bf8d55c896268466a9a003d85d02ba56f16b1a4689e6abec0ce |
File details
Details for the file mkdocs_sql-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_sql-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 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 | ed73e7cbaae8c6817f683cd5ceda52dd5ed078e39d780e7477c0b413392d7312 |
|
MD5 | 83a404d52013bb30312c024209b74e65 |
|
BLAKE2b-256 | fb35cf64c0023c878aa3f37acad70f552c79364da5fc8daee7feef8db50bd9a8 |