Skip to content

Instantly share code, notes, and snippets.

@knbknb
Last active May 2, 2024 06:42
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.
Create ER diagram from CSV files describing a relational DB schema using "sql2dbml" tool

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