Back to articles list
- 2 minutes read

Visual Design of SQLAlchemy Models in 6 Steps

In this article I’m going to show you how to design SQLAlchemy models using Vertabelo, an online tool for visual database design, and our code generator.

SQLAlchemy is propably the most advanced and well engineered OR/M for Python, while Vertabelo is a database design tool that works in a web browser. The Vertabelo code generator is an pythonic script called vertabelo-sqlalchemy. As you can see, the script is open source and hosted on GitHub.

Here we go:

  1. Download the SQLAlchemy models generator from GitHub.

          git clone https://github.com/Vertabelo/vertabelo-sqlalchemy.git
        

  2. Sign in to Vertabelo.

    Notice that Vertabelo is completely free for students and lecturers. (The academic registration is available here.) The others can use our free trial.

  3. Create a new database model.

    You may use an example database structure for a simple online store:

  4. Here is a sample model. You may make changes or leave the model untouched.




  5. Download diagram as an XML file.

  6. Generate SQLAlchemy models (notice: XML file name will be different).

    ./vertabelo_sqlalchemy.py -i Example_2014-12-01_13-02.xml \
                              -o model.py
    


That’s all. You’ve got model classes that correspond the database tables.

Vertabelo_sqlalchemy is still in alpha stage. Patches or pull request are highly welcome and don’t hesitate to raise an issue on GitHub :).

In the next blog article, I’ll write more details about code generation, including what is supported and what is not.

go to top

Our website uses cookies. By using this website, you agree to their use in accordance with the browser settings. You can modify your browser settings on your own. For more information see our Privacy Policy.