Live data from Hacker News

Show HN: Easily Visualize Your SQLAlchemy Data Models in a Nice SVG Diagram

github.com

1–10 of 19 posts

Re: Show HN: Easily Visualize Your SQLAlchemy Data Models in a Nice SVG Diagram

#2
I made this last week for fun, but I think it could be useful for people. If your application has pretty complicated SQLalchemy data models (and the app I'm working on now has gotten super complicated, with dozens of models with complex interconnections), then this very easily generates an attractive SVG that you can open in the browser showing all your tables and how they are connected. You can be up and running with this in less than a minute— just open it in Google Colab, replace the sample data models with your own, and run the notebook, and you should see the SVG displayed almost immediately at the bottom.

I attempted to also generate an HTML file containing the embedded SVG as well as some JS to enable nice interactive hover-on effects (I wanted to highlight the border of the table you hover over and then change all the outgoing connections to other tables to be red, and all incoming connections to that table to be green), but it wasn't working and started turning into a slog after an hour. If anyone knows how to do this, please submit a PR!

Re: Show HN: Easily Visualize Your SQLAlchemy Data Models in a Nice SVG Diagram

#4
post #3

gonna give it a try today, been wondering how come i never came across anything like that actually (been using the different clients tools)

Yeah, it was a bit weird to me that I couldn’t find anything like this either, which is why I made it. Seems like all the visualization tools out there go from the database tables directly, but that defeats the cross-database portability of SQLAlchemy which is one of its best features: it works equally well without any changes on SQLite, Postgres, etc.

Re: Show HN: Easily Visualize Your SQLAlchemy Data Models in a Nice SVG Diagram

#6
post #5

Nice. I've been using Django-schema-viewer and it's been great. This makes me wonder if its UI could be decoupled from Django...

Cool. Yeah it would seem to limit the audience a lot that it's for Django only and also has to be integrated into an existing Django project for it to work. I wanted a very small and simple tool that worked generically for any SQLAlchemy models. The core code of my tool is literally ~90 lines of Python-- the other ~200 lines are all the sample data models I include. That's because all the real heavy lifting is done by graphviz.

Re: Show HN: Easily Visualize Your SQLAlchemy Data Models in a Nice SVG Diagram

#8
post #3

gonna give it a try today, been wondering how come i never came across anything like that actually (been using the different clients tools)

Yeah, it was a bit weird to me that I couldn’t find anything like this either, which is why I made it. Seems like all the visualization tools out there go from the database tables directly, but that defeats the cross-database portability of SQLAlchemy which is one of its best features: it works equally well without any changes on SQLite, Postgres, etc.

Your tool looks great.

In regards to difficulty finding alternatives, many database management tools (like DataGrip and Dbeaver) have ER diagram generators that work for all the types of databases the tools work for... so basically vendor agnostic. Other tools like Visio (blast from the past) do too.

Re: Show HN: Easily Visualize Your SQLAlchemy Data Models in a Nice SVG Diagram

#9

Earlier quoted context omitted.

Yeah, it was a bit weird to me that I couldn’t find anything like this either, which is why I made it. Seems like all the visualization tools out there go from the database tables directly, but that defeats the cross-database portability of SQLAlchemy which is one of its best features: it works equally well without any changes on SQLite, Postgres, etc.

Your tool looks great. In regards to difficulty finding alternatives, many database management tools (like DataGrip and Dbeaver) have ER diagram generators that work for all the types of databases the tools work for... so basically vendor agnostic. Other tools like Visio (blast from the past) do too.

Sure, I meant something that could take SQLAlchemy data models as input and that was totally open source and free.
Post reply on HN