## 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 銆丼QLAlchemy2.0.25.
* Support for generate controller layer.
* Support for generate Model layer include many model py files.
* 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 sqlalchemy-codegen
```
Without pip:
```sh
git clone https://gitee.com/ncepu-bj/sqlalchemy-codegen.git
cd sqlalchemy-codegen/
python setup.py install
```
For contributing:
```sh
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:
```sh
sqlalchemy-codegen mysql+pymysql://root:password@ip:port/database --flask --models_layer --controller_layer --outdir dist
```
example:
```sh
sqlalchemy-codegen mysql+pymysql://root:123456@127.0.0.1:3306/testdb --flask --models_layer --controller_layer --outdir dist
```
or:
```sh
sqlalchemy-codegen mysql+pymysql://root:123456@127.0.0.1:3306/testdb --models_layer --controller_layer --outdir dist
```
Raw data
{
"_id": null,
"home_page": "",
"name": "sqlalchemy-codegen",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "sqlalchemy,flask-sqlalchemy,sqlacodegen,flask",
"author": "iDeal-ncepu",
"author_email": "",
"download_url": "",
"platform": null,
"description": "## sqlalchemy-codegen\r\n\r\n#### features\r\nThis 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.\r\n\r\nCode repository and related addresses: \r\ngithub:https://github.com/ncepu-iDealStudio/sqlalchemy-codegen;\r\n\r\ngitee:https://gitee.com/ncepu-bj/sqlalchemy-codegen;\r\n\r\ndocument:https://idealstudio-ncepu.yuque.com/docs/share/b5dcc5ff-fcba-4efd-8955-faeba859bfcf;\r\n\r\npypi:https://pypi.org/project/sqlalchemy-codegen/\r\n\r\n\r\nWhat's new and different:\r\n* Support python3.12 and sqlacodegen3.0.0rc3 \u9286\u4e3cQLAlchemy2.0.25.\r\n* Support for generate controller layer.\r\n* Support for generate Model layer include many model py files.\r\n* Support for Flask-SQLAlchemy syntax using `--flask` option.\r\n* Defaults to generating backrefs in relationships. `--nobackref` still included as option in case backrefs are not wanted. \r\n* 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).\r\n* Primary joins are explicit.\r\n* 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.\r\n* `--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`.\r\n* Uses the command `flask-sqlacodegen` instead of `sqlacodegen`.\r\n* Added support for `--notables` to only generate model classes, even for association tables\r\n\r\n## Install\r\n\r\nWith pip:\r\n```sh\r\npip install sqlalchemy-codegen\r\n```\r\n\r\nWithout pip:\r\n```sh\r\ngit clone https://gitee.com/ncepu-bj/sqlalchemy-codegen.git\r\ncd sqlalchemy-codegen/\r\npython setup.py install\r\n```\r\n\r\nFor contributing:\r\n```sh\r\ngit clone https://gitee.com/ncepu-bj/sqlalchemy-codegen\r\npython -m venv env\r\npip install -r requirements.txt\r\npython -m codegen.main mysql+pymysql://<username>:<password>@<database-ip>:<port>/<database-name> --flask --models_layer --controller_layer --outdir ddist[--tables <tablenames>] [--notables] \r\n```\r\n\r\nHow To use:\r\n```sh\r\nsqlalchemy-codegen mysql+pymysql://root:password@ip:port/database --flask --models_layer --controller_layer --outdir dist\r\n```\r\n\r\nexample:\r\n```sh\r\nsqlalchemy-codegen mysql+pymysql://root:123456@127.0.0.1:3306/testdb --flask --models_layer --controller_layer --outdir dist\r\n```\r\nor:\r\n\r\n```sh\r\nsqlalchemy-codegen mysql+pymysql://root:123456@127.0.0.1:3306/testdb --models_layer --controller_layer --outdir dist\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Automatic generate model layer and controller layer code for SQLAlchemy with Flask support",
"version": "1.1.1",
"project_urls": null,
"split_keywords": [
"sqlalchemy",
"flask-sqlalchemy",
"sqlacodegen",
"flask"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0c9596c515f783f36d542d56f683de53d430060e5dacc61941f94b23379d6950",
"md5": "0cf1558705a8c48bb355d432dd9aaab0",
"sha256": "5654de2c354d5c6bfee50fc1393669dfdd9477314618bd58b1257d7dfa9f638f"
},
"downloads": -1,
"filename": "sqlalchemy_codegen-1.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "0cf1558705a8c48bb355d432dd9aaab0",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 29596,
"upload_time": "2024-01-14T02:51:40",
"upload_time_iso_8601": "2024-01-14T02:51:40.631905Z",
"url": "https://files.pythonhosted.org/packages/0c/95/96c515f783f36d542d56f683de53d430060e5dacc61941f94b23379d6950/sqlalchemy_codegen-1.1.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-14 02:51:40",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "sqlalchemy-codegen"
}