Convert rows from a MySQL table into Obsidian notes with YAML frontmatter and generate a corresponding .base file for the Bases core plugin.
- 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)
Recommended (pipx):
pipx install mysql-to-obsidian-basesOr pip (user site):
python3 -m pip install --user mysql-to-obsidian-bases
# Ensure ~/.local/bin is on PATH (Linux/macOS)PyPI: https://pypi.org/project/mysql-to-obsidian-bases/
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 titleExport all tables:
mysql-to-bases \
--host 127.0.0.1 \
--user root \
--password secret \
--database mydb \
--all-tablesOr 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
mysql-to-bases \
--host 127.0.0.1 --user root --password secret --database library \
--table books --id-column id --title-column titleThis 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.
- 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.
--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
Project structure:
mysql_to_obsidian_bases/
__init__.py
__main__.py
cli.py
mysql_utils.py
type_inference.py
markdown_generator.py
base_generator.py
Developer install:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .Run locally:
mysql-to-bases --helpMIT