Live data from Hacker News

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

github.com

11–19 of 19 posts

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

#11

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 wit…

Nice, I hacked together something similar many moons ago, it looks like some fine folks have kept on maintaining and improving it: https://github.com/fschulze/sqlalchemy_schemadisplay

Useful to have in a CICD pipeline so you always have an up-to-date schema diagram available.

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

#13
post #11

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 wit…

Nice, I hacked together something similar many moons ago, it looks like some fine folks have kept on maintaining and improving it: https://github.com/fschulze/sqlalchemy_schemadisplay Useful to have in a CICD pipeline so you always have an up-to-date schema diagram available.

Cool, I'm surprised I couldn't find this when I was looking for something like this originally. Probably because I was using different terminology-- "data model" instead of "schema," and "visualize" instead of "display".

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

#14
I see this is using Graphviz. The first time I used DOT, I was writing a parser and wanted to visualize my AST. It was fantastic and so easy to write, especially if you have a wrapper library. It's such a great tool for being able to visualize your graphs.

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

#15
post #14

I see this is using Graphviz. The first time I used DOT, I was writing a parser and wanted to visualize my AST. It was fantastic and so easy to write, especially if you have a wrapper library. It's such a great tool for being able to visualize your graphs.

Yes, Graphviz is doing all the actual hard work here. It's an awesome library.

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

#17
>>> from sqlalchemy_data_model_visualizer import generate_data_model_diagram

python3.11/site-packages/sqlalchemy_data_model_visualizer.py", line 5, in from sqlalchemy.orm import sessionmaker, declarative_base, relationship ImportError: cannot import name 'declarative_base' from 'sqlalchemy.orm'

doesn't work with the older sqlalchemy

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

#18

>>> from sqlalchemy_data_model_visualizer import generate_data_model_diagram python3.11/site-packages/sqlalchemy_data_model_visualizer.py", line 5, in from sqlalchemy.orm import sessionmaker, declarative_base, relationship ImportError: cannot import name 'declarative_base' from 'sqlalchemy.orm' doesn't work with the older sqlalchemy

from sqlalchemy.orm import sessionmaker, relationship from sqlalchemy.ext.declarative import declarative_base

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

#19

This is great, especially to introduce new devs to models. I use (and love) TablePlus ( https://tableplus.com/ ) which has a diagram generator plugin that does the same!

I don't have a formal compsci background but one of the most enlightening things I've undertaken recently was a course involving data modeling. this seems like an important exercise many overlook.
Post reply on HN