Skip to content

Add ER diagram with FK introspection across all databases#201

Open
dcpatrick15 wants to merge 2 commits into
Maxteabag:mainfrom
dcpatrick15:feature/er-diagram
Open

Add ER diagram with FK introspection across all databases#201
dcpatrick15 wants to merge 2 commits into
Maxteabag:mainfrom
dcpatrick15:feature/er-diagram

Conversation

@dcpatrick15
Copy link
Copy Markdown

@dcpatrick15 dcpatrick15 commented May 12, 2026

Summary

  • ER diagram feature: select tables from the explorer, view columns with PK/FK markers, and relationship lines between tables
  • FK introspection (get_foreign_keys()) implemented for all 14 remaining database adapters
  • 42 unit tests + integration test coverage across 8 databases (PostgreSQL, MySQL, MariaDB, MSSQL, Oracle, Firebird, DuckDB, Turso, SQLite)

How to use

  1. Select a table in the explorer
  2. Press d to open the ER diagram for that table
  3. To view multiple tables: press D to open the table picker, select tables with space, confirm with enter
  4. Scroll with hjkl, close with q

Screenshots

Screenshot_20260512_145600 Screenshot_20260512_145643 Screenshot_20260512_145710 Screenshot_20260512_145722

Test plan

  • Unit tests: pytest tests/unit/test_foreign_keys.py -v (42 tests)
  • Integration tests: pytest tests/ -v -k test_get_foreign_keys (8 databases verified locally with Docker)
  • Existing diagram tests: pytest tests/unit/test_diagram_layout.py -v

Adds the ability to generate Unicode ER diagrams showing tables, columns
(with PK/FK markers), and foreign key relationship lines. Accessible via
S key on explorer tree nodes and space+d leader menu for a table picker
modal. Includes FK introspection for PostgreSQL and SQLite providers.
Implements FK introspection for MySQL, MariaDB, MSSQL, Oracle, Firebird,
DuckDB, Turso, Snowflake, Spanner, HANA, DB2, Teradata, Redshift, and
MotherDuck. Each adapter queries the database's native metadata catalog
to return ForeignKeyInfo objects used by the ER diagram feature.

Includes 42 unit tests with mocked cursors and integration test coverage
via BaseDatabaseTests. All 9 test fixtures updated with test_orders FK table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant