enkeksi - Markdown-SQL evaluator
Package author: Jukka Aho (@ahojukka5, ahojukka5@gmail.com)
enkeksi takes a markdown-formatted input and executes the sql queries found in it, and returns a markdown-formatted output where the results of the sql queries have been added. Package can be used, for example, to create a dynamic project documentation where SQL queries are automatically executed to get example results in a dynamic manner. This way it is easy to spot from the non-working documentation is there is problems with the database.
enkeksi comes with a command line tool markdown-sql-eval which can be used
to process markdown files efficiently.
Project is hosted in GitHub: https://github.com/ahojukka5/enkeksi.
Documentation is hosted in ReadTheDocs: https://enkeksi.readthedocs.io/.
Installing package
To install the most recent package from Python Package Index (PyPi), use git:
pip install enkeksi
To install the development version, you can install the package directly from the GitHub:
pip install git+git://github.com/ahojukka5/enkeksi.git
CLI Usage
Consider the following demo markdown file:
# Sample file
Hello, this is a sample file. Below, we initialize some test data to sqlite
database. It doesn't show in the final output, because of `--hide-input` flag.
```sql
--hide-input
CREATE TABLE Movies (id INTEGER PRIMARY KEY, name TEXT, year INTEGER);
INSERT INTO Movies (name, year) VALUES ("Snow White", 1937);
INSERT INTO Movies (name, year) VALUES ("Fantasia", 1940);
```
To list the content of the database, we need to use `SELECT` in SQL query. We
can use extra option `--caption='Table: Movies'` to add caption to output:
```sql
--hide-input --caption='Table: Movies'
SELECT * FROM Movies;
```
SQL results are formatted using [tabulate](https://pypi.org/project/tabulate/).
Using option `--table-format` we can change how the end results looks like.
By default, `psgl` is used and there rest options can be found from tabulate's
documentation. The total number of rows in database is:
```sql
--caption='With psql formatting'
SELECT COUNT(*) AS 'Number of movies in database' FROM Movies;
```
Option `--hide-headers` can be used to hide the header row of the result.
```sql
--table-format='github' --hide-headers --caption='With github formatting and headers removed'
SELECT COUNT(*) AS 'Now shown' FROM Movies;
```
Processing the file with markdown-sql-eval:
markdown-sql-eval examples/example2.md > examples/example2_rendered.md
Result is:
# Sample file
Hello, this is a sample file. Below, we initialize some test data to sqlite
database. It doesn't show in the final output, because of `--hide-input` flag.
To list the content of the database, we need to use `SELECT` in SQL query. We
can use extra option `--caption='Table: Movies'` to add caption to output:
```text
Table: Movies
+------+------------+--------+
| id | name | year |
|------+------------+--------|
| 1 | Snow White | 1937 |
| 2 | Fantasia | 1940 |
+------+------------+--------+
```
SQL results are formatted using [tabulate](https://pypi.org/project/tabulate/).
Using option `--table-format` we can change how the end results looks like.
By default, `psgl` is used and there rest options can be found from tabulate's
documentation. The total number of rows in database is:
```sql
SELECT COUNT(*) AS 'Number of movies in database' FROM Movies;
```
```text
With psql formatting
+--------------------------------+
| Number of movies in database |
|--------------------------------|
| 2 |
+--------------------------------+
```
Option `--hide-headers` can be used to hide the header row of the result.
```sql
SELECT COUNT(*) AS 'Now shown' FROM Movies;
```
```text
With github formatting and headers removed
|---|
| 2 |
```
The generated markdown file can then be added to your project documentation
and hosted using e.g. mkdocs. For that idea, take a look of docs/demo.md,
which is hosted in here,
and generated from docs/demo_tmpl.md.
Contributing
Contributions are welcome as usual. If you have any good idea, and especially, a better name for a package, raise an issue.
Metadata
Release files for enkeksi 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| enkeksi-0.3.0.tar.gz | 5.2 kB | Without provenance | Details for enkeksi-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| enkeksi-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for enkeksi-0.3.0-py3-none-any.whl |
Total release size: 11.1 kB
Release files / enkeksi-0.3.0.tar.gz
| Download URL | enkeksi-0.3.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87d6eda0de5b337da19ba1eed2bd0767add279e81534de434a2c23cfd45af2dd
|
|
BLAKE2b-256 checksum How to use checksums |
1b8cab51d9cfa33f054030cc4686b9cef2c48798a527f43e66fae2c719714853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
|
Release files / enkeksi-0.3.0-py3-none-any.whl
| Download URL | enkeksi-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f77bac3b3ee1428685df2b0b81bec3c9c05d75d52ffc0f66767b1d12a6b333c
|
|
BLAKE2b-256 checksum How to use checksums |
6d211a12cee96420ecdcccffa862e3ccf4d5899445a8c97a4f43a4c25496c722
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
|
Security for enkeksi 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.