开发者

Is there any database model designer that can output SQLAlchemy models?

I am implementing a database model to store the 20+ fields of the iCal calendar format and am faced with tediously typing in all these into an SQLAlchemy model.py file. Is there a smarter approach? I am looking for a GUI or model designer that can create the model.py file for me. I would specify the column names and some attributes, e.g, type, length, etc.

At the minimum, I need this designer to output a model for one table. Additional requirements, in decreasing order of priority:

  • Create multiple tables
  • Support basic relationships between the multiple tables (1:1, 1:n)
  • Support constraints on the columns.

I am also open to o开发者_开发百科ther ways of achieving the goal, perhaps using a GUI to create the tables in the database and then reflecting them back into a model.

I appreciate your feedback in advance.


There's another way yet to generate an SQLAlchemy model. You can use Vertabelo - it's an online tool for visual database designing. It's completely free for small projects.

After you created your model in Vertabelo, you will have to convert it to SQLAlchemy mapping classes by using a script available on GitHub.

Simply follow provided below steps:

  • Download diagram as XML file (simply press an XML icon on the toolbar menu)

  • Generate SQLAlchemy models

./vertabelo_sqlalchemy.py -i your_diagram.xml -o model.py

I know this is not a direct and perfect way, but hope it will suit you.


"I would specify the column names and some attributes, e.g, type, length, etc."

Isn't that the exact same thing as

"tediously typing in all these into an SQLAlchemy model.py file"?

If those two things aren't identical, please explain how they're different.


I Just found workbench_alchemy a script plugin for MySQL Workbench.

Haven't used it much yet but it looks great so far!. Easy to install. There is an option to make output compatible with SQlite. The script logs inside MySQL Workbench, so you can see what's going on.

Also good for the tool chain is an SQL WB Plugin, mysql-wb-exportsqlite that can export an SQlite create script.

I'm on MySQL Workbench 6.2 (Debian apt-get one), but the script also works with 6.3 vers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜