Skip to content

Instantly share code, notes, and snippets.

@knbknb
Last active January 25, 2025 15:11
Show Gist options
  • Save knbknb/244f26662b6e1c629bd03387d3d8e7fc to your computer and use it in GitHub Desktop.
Save knbknb/244f26662b6e1c629bd03387d3d8e7fc to your computer and use it in GitHub Desktop.
"sql2dbml" tool: ER diagram from CSV files w relational DB schema info
Create ER Diagram from CSV files forming the database schema using "sql2dbml" tool

Load database into Sqlite

# install from pypy
sqlite-utils insert trees.db  myfile.csv

Show full schema for this database or for specified tables

sqlite-utils schema trees.db

Install sql2dbml (a free Node app) to convert SQL schema to dbml

npm install -g sql2dbml

Run sql2dbml to convert SQL schema to dbml

sql2dbml -i trees.sql -o trees.dbml

Create ER Diagram from the schema by pasting in the DBML file into dbdiagram.io

Alternatively

Create an "interactive ER diagram" by importing sqlite into a software with a graphical query builder, such as:

  • MS Access (connect to sqlite via ODBC)
  • Libreoffice Base (connect to sqlite via ODBC)
  • DBeaver (I think it has a graphical query tool)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment