Automatic model code generator for SQLAlchemy with Flask support
Project description
Flask sqlacodegen
Fork of sqlacodegen by Alex Gronholm. Based off of version 1.1.6.
What's different:
- Support for Flask-SQLAlchemy syntax using
--flask
option. - Defaults to generating backrefs in relationships.
--nobackref
still included as option in case backrefs are not wanted. - Naming of backrefs is class name in snake_case (as opposed to CamelCase) and is pluralized if it's Many-to-One or Many-to-Many using inflect.
- Primary joins are explicit.
- If column has a server_default set it to
FetchValue()
instead of trying to determine what that value is. Original code did not set the right server defaults in my setup. --ignore-cols
ignores special columns when generating association tables. Original code requires all columns to be foreign keys in order to generate association table. Example:--ignore-cols id,inserted,updated
.- Uses the command
flask-sqlacodegen
instead ofsqlacodegen
. - Added support for
--notables
to only generate model classes, even for association tables
Install
With pip:
pip install flask-sqlacodegen
Without pip:
git clone https://github.com/ksindi/flask-sqlacodegen.git
cd flask-sqlacodegen/
python setup.py install
For contributing:
git clone https://github.com/ksindi/flask-sqlacodegen.git
python -m venv env
pip install -r requirements.txt
python -m sqlacodegen.main --flask --outfile models.py mysql+pymysql://<username>:<password>@<database-ip>:<port>/<database-name> [--tables <tablenames>] [--notables]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flask-sqlacodegen-1.1.8.tar.gz
(12.5 kB
view hashes)
Built Distribution
Close
Hashes for flask_sqlacodegen-1.1.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cf05501f33703cc52279e98973a52d7ae475e16ef28c17fcdf99ac9b8db61fb |
|
MD5 | d76b697d6c0c5032affb3b3d970b7956 |
|
BLAKE2b-256 | 1dc68291762360b426ed46b6d90765a3037de48862320586e50d21c71bbaa51d |