Skip to content Skip to sidebar Skip to footer

Generating Models For Flask-appbuilder Using Flask-sqlqcodegen

I'm a beginner in Python and Flask ecosystems, trying to create a small proof-of-concept Web application for a research project. I'm using Debian Linux 7.9, PostgreSQL 9.5, SQLAlch

Solution 1:

Upon some Internet searching, I ran across an issue on GitHub, which described exactly the same problem. However, the most recent recommendation at the time produced another error instead of the original one. In the discussion with the author of flask-sqlcodegen, it appeared that there exist a pull request (PR) kindly provided by a project contributor that apparently should fix the problem. After updating my local repository, followed by rebuilding and reinstalling the software, I was able to successfully generate models for my database. The whole process consists of the following steps.

  1. Change to directory with a local repo of flask-sqlcodegen.
  2. If you made any changes, like I did, stash them: git stash.
  3. Update repo: git pull origin master (now includes that PR).
  4. Rebuild/install software: python setup.py install.
  5. If you need your prior changes, restore them: git stash pop. Otherwise, discard them: git reset --hard.
  6. Change to your Flask application directory and auto-generate the models, as follows.

    sqlacodegen --flask --outfile models.py postgresql+psycopg2://USER:PASS@HOST/DBNAME

Acknowledgements: Big thank you to Kamil Sindi (the flask-sqlcodegen's author) for the nice software and rapid & helpful feedback as well as to Alisdair Venn for that valuable pull request.

Post a Comment for "Generating Models For Flask-appbuilder Using Flask-sqlqcodegen"