Pycharm Database diagram sqlalchemy flask

I cannot get SQLAlchemy model dependancy diagrams to show anything in Pycharm.

I am using SQLAlchemy in a 'flask' project and wonder if that is the cause for the issue?

SQLalchemys hooks are provided by Flask-SQLAlchemy which may be hiding the db or models from Pycharm.

 

Anyone able to get database diagrams working in a flask project?

 

 

1
4 comments

Yes. I am creating SQLAlchemy Model Dependency Diagram for Flask-SQLAlchemy. PyCharm 2016.1.2. But there is an another issue. This diagram contains only those models which inherited from db.Model. Any Model which is inherited from model which is inherited from db.Model is not displayed.

0
Avatar
Permanently deleted user

@Valeriy, How did you manage to get it working? Have you done anything specific in the configuration to make it work?

Currently I am getting only a blank diagram no matter if I select the project or any sub-directory or even the models.py.

Offcouse, db = SQLAlchemy() # from the Flask-SQLAlchemy extension

0

Hello, @Marin Ivanov.

I just test it on my that project from my previous message, and I created empty Flask project and test it there. SQLAlchemy Model Dependency Diagram works. My current PyCharm version is 2016.2.3. I did not doing something specific. You just should use Models inherited from db.Model, where `from flask_sqlalchemy import SQLAlchemy; db = SQLAlchemy()`. If you rename db to db2 for example (`from tmp_extensions import db as db2`) diagram will not work (it will blank). If you will inherit your models not from db.Model, but from another model class which is inherited from db.Model then this diagram will not work also (it will blank).

If it is still not working for you please show your source code. I can check it in my environment

 

0
Avatar
Permanently deleted user

It seems that it works now. I am sure I was also running 2016.2.3 at the time of my previous post and right now also. I don't really know what was the issue, but I had to reconfigure the project a few times and this may have fixed the things for me.

There is still an issue that I am facing right now is that I cannot see the relationships between the entities. It is quite the reason I wanted the diagram in first place, but I am now familiar with the project and I don't need that diagram anymore.

Thank you.

0

Please sign in to leave a comment.