MySQL → Obsidian Bases (CLI)
Convert rows from a MySQL table into Obsidian notes with YAML frontmatter and generate a corresponding .base file for the Bases core plugin.
Features
- Connects to MySQL using CLI flags
- Exports each row to a Markdown file with properly-typed frontmatter
- Infers property types from MySQL schema (numbers, dates, datetimes, booleans, text)
- Generates a
.basefile that filters to the exported folder and provides a default Table view - Idempotent by default (overwrites files with the same name)
Install
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
Usage
Preferred (console script):
mysql-to-bases \
--host 127.0.0.1 \
--user root \
--password secret \
--database mydb \
--table books \
--output /absolute/path/to/output \
--id-column id \
--title-column title
Export all tables:
mysql-to-bases \
--host 127.0.0.1 \
--user root \
--password secret \
--database mydb \
--all-tables
Or via module:
python -m mysql_to_obsidian_bases --help
- You must specify either
--table <name>or--all-tables. - --host/--user/--password/--database/--port: MySQL connection
- --table: Table name to export
- --all-tables: Export every base table found in the database
- --output: Output directory for the base folder (default:
./output/<table>-base) - --id-column: Column used for filenames (default:
idor first column) - --title-column: Column used as the H1 title inside the note (optional)
After running, you'll have:
output/<table>-base/notes/with one.mdfile per rowoutput/<table>-base/<table>.basewith a default Table view filtered to the above folder
Example
mysql-to-bases \
--host 127.0.0.1 --user root --password secret --database library \
--table books --id-column id --title-column title
This creates something like:
output/books-base/
books.base
notes/
1.md
the-hitchhikers-guide-to-the-galaxy.md
...
Tip: Move the generated folder into your Obsidian vault. The .base file includes a filter that limits results to the notes/ subfolder.
Notes on Types and Formatting
- Dates (
DATE) are formatted asYYYY-MM-DD - Datetimes (
DATETIME,TIMESTAMP) are formatted asYYYY-MM-DD HH:mm:ss - Booleans (
TINYINT(1)) becometrue/false - Numbers remain numbers
- Strings are emitted as YAML strings when necessary
The .base file sets a global filter file.inFolder("<table>-base/notes") to scope the view to the generated notes.
Stretch Goals (not yet implemented)
--queryto use a custom SQL query (type inference is trickier when not tied to a single table)- Incremental updates (append-only or merge strategies)
- Per-column type overrides via a config file
Development
Project structure:
mysql_to_obsidian_bases/
__init__.py
__main__.py
cli.py
mysql_utils.py
type_inference.py
markdown_generator.py
base_generator.py
Run locally:
mysql-to-bases --help
License
MIT
Metadata
Release files for mysql-to-obsidian-bases 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mysql_to_obsidian_bases-0.1.1.tar.gz | 19.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mysql_to_obsidian_bases-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.0 kB
Release files / mysql_to_obsidian_bases-0.1.1.tar.gz
| Download URL | mysql_to_obsidian_bases-0.1.1.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb02df6b66f988094d97e0c730d1b14794f59bd9d77b2c72473445f0821c0cfe
|
|
BLAKE2b-256 checksum How to use checksums |
5172e738aacc0a93fac2e326574e0b4cd8cb2a2cb088a6af7bf381243967b537
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.2
|
Release files / mysql_to_obsidian_bases-0.1.1-py3-none-any.whl
| Download URL | mysql_to_obsidian_bases-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89480bf3fdf0aa547e26066454723899fae2bef0a4dce5dbe08702e8d8519bd6
|
|
BLAKE2b-256 checksum How to use checksums |
ef62c47e0d11bd98c5cbaed22596640d2daae12f29331b81ea61d4e61ea9fd93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.2
|