Package: enkeksi
enkeksi - Markdown-SQL evaluatorPackage 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 toolmarkdown-sql-evalwhich 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 packageTo install the most recent package from Python Package Index (PyPi), use git:pipinstallenkeksiTo install the development version, you can install the package directly from
the GitHub:pipinstallgit+git://github.com/ahojukka5/enkeksi.gitCLI UsageConsider the following demo markdown file:# Sample fileHello, 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-inputCREATETABLEMovies(idINTEGERPRIMARYKEY,nameTEXT,yearINTEGER);INSERTINTOMovies(name,year)VALUES("Snow White",1937);INSERTINTOMovies(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*FROMMovies;```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'SELECTCOUNT(*)AS'Number of movies in database'FROMMovies;```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'SELECTCOUNT(*)AS'Now shown'FROMMovies;```Processing the file withmarkdown-sql-eval:markdown-sql-evalexamples/example2.md>examples/example2_rendered.mdResult is:# Sample fileHello, 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:```textTable: 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:```sqlSELECTCOUNT(*)AS'Number of movies in database'FROMMovies;``````textWith psql formatting

+--------------------------------+
|   Number of movies in database |
|--------------------------------|
|                              2 |
+--------------------------------+```Option`--hide-headers`can be used to hide the header row of the result.```sqlSELECTCOUNT(*)AS'Now shown'FROMMovies;``````textWith 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 ofdocs/demo.md,
which is hosted inhere,
and generated fromdocs/demo_tmpl.md.ContributingContributions are welcome as usual. If you have any good idea, and especially,
a better name for a package, raise an issue.