sqlalchemy-codegen
features
This is a tool that can generate corresponding Model and controller layer codes based on the sqlalchemy ORM framework through command-line operation. It supports generating codes for the entire database or for specific tables. Additionally, it supports generating codes based on the Flask framework.
Code repository and related addresses: github:https://github.com/ncepu-iDealStudio/sqlalchemy-codegen;
gitee:https://gitee.com/ncepu-bj/sqlalchemy-codegen;
document:https://idealstudio-ncepu.yuque.com/docs/share/b5dcc5ff-fcba-4efd-8955-faeba859bfcf;
pypi:https://pypi.org/project/sqlalchemy-codegen/
What's new and different:
- Support python3.12 and sqlacodegen3.0.0rc3 SQLAlchemy2.0.25.
- Support for generate controller layer.
- Support for generate Model layer include many model py files.
- Support for Flask-SQLAlchemy syntax using
--flaskoption. - Defaults to generating backrefs in relationships.
--nobackrefstill 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-colsignores 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-sqlacodegeninstead ofsqlacodegen. - Added support for
--notablesto only generate model classes, even for association tables
Install
With pip:
pip install sqlalchemy-codegen
Without pip:
git clone https://gitee.com/ncepu-bj/sqlalchemy-codegen.git
cd sqlalchemy-codegen/
python setup.py install
For contributing:
git clone https://gitee.com/ncepu-bj/sqlalchemy-codegen
python -m venv env
pip install -r requirements.txt
python -m codegen.main mysql+pymysql://<username>:<password>@<database-ip>:<port>/<database-name> --flask --models_layer --controller_layer --outdir ddist[--tables <tablenames>] [--notables]
How To use:
sqlalchemy-codegen mysql+pymysql://root:password@ip:port/database --flask --models_layer --controller_layer --outdir dist
example:
sqlalchemy-codegen mysql+pymysql://root:123456@127.0.0.1:3306/testdb --flask --models_layer --controller_layer --outdir dist
or:
sqlalchemy-codegen mysql+pymysql://root:123456@127.0.0.1:3306/testdb --models_layer --controller_layer --outdir dist
Metadata
Release files for sqlalchemy-codegen 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlalchemy_codegen-1.1.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for sqlalchemy_codegen-1.1.2-py2.py3-none-any.whl |
Release files / sqlalchemy_codegen-1.1.2-py2.py3-none-any.whl
| Download URL | sqlalchemy_codegen-1.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 29.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2f768aeaa109a240f43a55b468caf10e47ce9130e600ad06442c41c263a30d0c
|
|
BLAKE2b-256 checksum How to use checksums |
a3a3415f86817299f1a90f92456f041dc4ec9a6362ae730d33f6772cf77eea78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Security for sqlalchemy-codegen 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.