Skip to main content

Convert MySQL tables into Obsidian notes and Bases .base files

Project description

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 .base file 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: id or 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 .md file per row
  • output/<table>-base/<table>.base with 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 as YYYY-MM-DD
  • Datetimes (DATETIME, TIMESTAMP) are formatted as YYYY-MM-DD HH:mm:ss
  • Booleans (TINYINT(1)) become true/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)

  • --query to 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mysql_to_obsidian_bases-0.1.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mysql_to_obsidian_bases-0.1.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file mysql_to_obsidian_bases-0.1.1.tar.gz.

File metadata

  • Download URL: mysql_to_obsidian_bases-0.1.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.2

File hashes

Hashes for mysql_to_obsidian_bases-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eb02df6b66f988094d97e0c730d1b14794f59bd9d77b2c72473445f0821c0cfe
MD5 0776f169c631e8dbf4869b8d40fb7a69
BLAKE2b-256 5172e738aacc0a93fac2e326574e0b4cd8cb2a2cb088a6af7bf381243967b537

See more details on using hashes here.

File details

Details for the file mysql_to_obsidian_bases-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mysql_to_obsidian_bases-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89480bf3fdf0aa547e26066454723899fae2bef0a4dce5dbe08702e8d8519bd6
MD5 752dfa1ebf1590b8092622fb0f15fc50
BLAKE2b-256 ef62c47e0d11bd98c5cbaed22596640d2daae12f29331b81ea61d4e61ea9fd93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page