Execute SQL queries inside a markdown document
Project description
pandoc-run-postgres
Execute SQL queries inside a markdown document
Example
- Write a SQL query in a code block
``` run-postgres
SELECT oid, 'hello ' || rolname || '!' AS greetings from pg_roles
Limit 2;
```
- Call pandoc
export PGHOST=localhost
export PGDATABASE=foo
export PGUSER=bob
export PGPASSWORD=xxxxxxxx
pandoc --filter pandoc-run-postgres hello.md -o result.md
- The output will contain the SQL query inside a SQL codeblock and the result in a table:
```sql
SELECT oid,
'hello ' || rolname || '!' AS greetings
FROM pg_roles
LIMIT 2;
```
oid greetings
------ -----------------------------
33731 hello bob!
33748 hello alice!
Install
pip install pandoc-run-postgres
Configuration
See examples in sample.md.
Similar projects
- pandoc-filter-runsql for MySQL
- Jupyter's ipython-sql
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pandoc_run_postgres-0.1.0.tar.gz.
File metadata
- Download URL: pandoc_run_postgres-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b99327aaad1e8979c2578d55c0818aed5bb5507d0af6463bbe38c07c195ffe8
|
|
| MD5 |
de3a5dc9983a7bc51dabf53db927e426
|
|
| BLAKE2b-256 |
4d45ac1351144468ae136461d2f92603a3d100b6488c24bdfdfa80c25a35ae14
|
File details
Details for the file pandoc_run_postgres-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pandoc_run_postgres-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89e874d913a5777d8576188cfb93386c92dc8f98a56bc1da4ecc5e4c5171daba
|
|
| MD5 |
ccfc41cbc27b33d916db243fb6c51e1a
|
|
| BLAKE2b-256 |
0613b2e0028054c9fd2069a0bc26a1704b5bf9c7de61bb7ac192e8255949bb25
|