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
File details
Details for the file pandoc-run-postgres-0.0.4.tar.gz
.
File metadata
- Download URL: pandoc-run-postgres-0.0.4.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 146037f36567dda34177a97547a17a945abb210c04356ff0b07b111ba9f43f97 |
|
MD5 | 7d449886241e079beb1394a8756b9fb8 |
|
BLAKE2b-256 | df9254c62acb7bb0664a73887931981903d351034bfe220fcb9111882ac42b5e |
File details
Details for the file pandoc_run_postgres-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: pandoc_run_postgres-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edb3d6fc5ceef800eb12c32f51a55a73d0789830a5a1658459d2d5eb76e41cfb |
|
MD5 | b863c7ee57c51b3ac5b50038a183843e |
|
BLAKE2b-256 | 94993813035af46c04bbfbc275a0737483c7ee0fd15159ba9c9a1fa7e5f1bbe8 |