Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ksindi/flask-sqlacodegen
:sake: Automatic model code generator for SQLAlchemy with Flask support
https://github.com/ksindi/flask-sqlacodegen
flask flask-sqlacodegen python sqlacodegen sqlalchemy
Last synced: 1 day ago
JSON representation
:sake: Automatic model code generator for SQLAlchemy with Flask support
- Host: GitHub
- URL: https://github.com/ksindi/flask-sqlacodegen
- Owner: ksindi
- License: other
- Created: 2014-04-13T17:06:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-07-09T17:47:39.000Z (6 months ago)
- Last Synced: 2025-01-03T17:04:46.844Z (8 days ago)
- Topics: flask, flask-sqlacodegen, python, sqlacodegen, sqlalchemy
- Language: Python
- Homepage:
- Size: 116 KB
- Stars: 336
- Watchers: 19
- Forks: 58
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ksindi/flask-sqlacodegen - :sake: Automatic model code generator for SQLAlchemy with Flask support (Python)
README
# Flask sqlacodegen
Fork of [sqlacodegen](https://pypi.python.org/pypi/sqlacodegen) by Alex Gronholm.
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](https://pypi.python.org/pypi/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 of `sqlacodegen`.
* Added support for `--notables` to only generate model classes, even for association tables## Install
With pip:
```sh
pip install flask-sqlacodegen
```Without pip:
```sh
git clone https://github.com/ksindi/flask-sqlacodegen.git
cd flask-sqlacodegen/
python setup.py install
```For contributing:
```sh
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://:@:/ [--tables ] [--notables]
```