https://github.com/freedom35/python-sqlite-to-markdown
Python app to export SQLite query results to markdown.
https://github.com/freedom35/python-sqlite-to-markdown
database markdown python sqlite
Last synced: about 2 months ago
JSON representation
Python app to export SQLite query results to markdown.
- Host: GitHub
- URL: https://github.com/freedom35/python-sqlite-to-markdown
- Owner: freedom35
- License: mit
- Created: 2023-01-03T22:27:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T20:55:30.000Z (about 2 years ago)
- Last Synced: 2025-08-04T07:36:34.303Z (11 months ago)
- Topics: database, markdown, python, sqlite
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQLite Results to Markdown
This repo contains a Python app to export the results of a SQLite query to a [markdown](https://www.markdownguide.org) file.
This software may be used/updated under the terms of the **MIT license**.
## Requirements
* [Python 3](https://www.python.org/downloads/)
## Usage
The app is expecting the following command line args:
|Arg|Description|
|---|---|
|1st|Path to SQLite database file|
|2nd|Path to SQL file containing source query|
|3rd (Optional)|Directory where markdown file will be created|
Note: The markdown file created will have the same filename as the input sql file, but with the extension changed to **md**.
Example:
```sh
$ python3 exportmd.py sample.db query.sql
```
In this case, a *query.md* file with the results will be created in the current directory - the same directory as the *query.sql* file.
Example with optional export directory:
```sh
$ python3 exportmd.py sample.db query.sql export-data
```
In this case, a *query.md* file with the results will be created in the *export-data* directory.
## Markdown File
The contents of the markdown file will depend on the query file and the results it produces. The markdown file will contain the following:
1. A heading based on query filename.
2. If the query file contains any SQL comments at the top of the file, these will be exported to the markdown file.
3. The query results will be converted to a markdown table, with the field names being used as the table headings.
An example of the output format is shown below:
```
# query-filename-without-ext
Optional comment(s) from start of query file.
|ID|Value|
|:-:|---|
|1|Value A|
|2|Value B|
```
Note: Numeric fields will be center aligned, normal text will be left aligned.