Metadata-Version: 2.1
Name: starlette-utils
Version: 0.0.1
Summary: starlette Tools.
Home-page: https://gitee.com/hubertshelley/starlette_utils
Author: Hubert Shelley
Author-email: hubertshelley@163.com
License: Apache Software License
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.7.0
Description-Content-Type: text/markdown


# Starlette_utils

starlette工具包

![avatar](https://cdn.smart7.tech/static/img/Perfect7.png)

## 项目依赖

|  包名   | 版本  |
|  ----  | ----  |
| [marshmallow] |  ≥ 3.13.0 |
| [starlette] |  ≥ 0.16.0 |
| [starlette-apispec] |  ≥ 1.0.4 |
| [smart7-orm] | 1.0.0 |
[comment]: <> (## 配置数据库)

[comment]: <> (### 0x01 项目根目录配置settings.py)

[comment]: <> (```python)

[comment]: <> (# mysql setting)

[comment]: <> (database = {)

[comment]: <> (    "db": 'MySQL',)

[comment]: <> (    "host": "localhost",)

[comment]: <> (    "username": "hubert",)

[comment]: <> (    "password": "hubert",)

[comment]: <> (    "db_name": "test_table",)

[comment]: <> (})

[comment]: <> (```)

[comment]: <> (```python)

[comment]: <> (# PostgreSQL setting)

[comment]: <> (database = {)

[comment]: <> (    "db": 'PostgreSQL',)

[comment]: <> (    "host": "localhost",)

[comment]: <> (    "username": "hubert",)

[comment]: <> (    "password": "hubert",)

[comment]: <> (    "db_name": "test_table",)

[comment]: <> (})

[comment]: <> (```)

[comment]: <> (```python)

[comment]: <> (# sqlite setting)

[comment]: <> (database = {)

[comment]: <> (    "db": 'SQLite',)

[comment]: <> (    "db_name": "test_table.db",)

[comment]: <> (})

[comment]: <> (```)

[comment]: <> (### 0x02 自动获取模型所在包)

[comment]: <> (```python)

[comment]: <> (from smart7_orm.utils import discover_models)

[comment]: <> (model_list = discover_models&#40;&#41;)

[comment]: <> (```)

[comment]: <> (### 0x03 数据库设置)

[comment]: <> (```python)

[comment]: <> (from smart7_orm.core import make_sql)

[comment]: <> (from smart7_orm.utils import discover_models)

[comment]: <> (TORTOISE_ORM = {)

[comment]: <> (    "connections": {"default": make_sql&#40;&#41;.get_url&#40;&#41;},)

[comment]: <> (    "apps": {)

[comment]: <> (        "models": {)

[comment]: <> (            "models": ["aerich.models", *discover_models&#40;&#41;],)

[comment]: <> (            "default_connection": "default",)

[comment]: <> (        },)

[comment]: <> (    },)

[comment]: <> (})

[comment]: <> (```)

[comment]: <> (## 迁移数据库)

[comment]: <> (### 0x01 初始化迁移配置)

[comment]: <> (```shell)

[comment]: <> (aerich init)

[comment]: <> (```)

[comment]: <> (### 0x02 初始化数据库)

[comment]: <> (```shell)

[comment]: <> (aerich init-db)

[comment]: <> (```)

[comment]: <> (### 0x03 更新模型并进行迁移)

[comment]: <> (```shell)

[comment]: <> (aerich migrate)

[comment]: <> (```)

[comment]: <> (### 0x04 升级到最新版本)

[comment]: <> (```shell)

[comment]: <> (aerich upgrade)

[comment]: <> (```)

[comment]: <> (### 0x05 降级到指定版本)

[comment]: <> (```shell)

[comment]: <> (aerich downgrade)

[comment]: <> (```)

[comment]: <> (### 0x06 显示历史)

[comment]: <> (```shell)

[comment]: <> (aerich history)

[comment]: <> (```)

[comment]: <> (### 0x06 显示要迁移的头)

[comment]: <> (```shell)

[comment]: <> (aerich heads)

[comment]: <> (```)

[comment]: <> (更多请查看 [aerich] github)

[marshmallow]: https://marshmallow.readthedocs.io/
[starlette]: https://www.starlette.io
[starlette-apispec]: https://apispec.readthedocs.io/en/stable/
[smart7-orm]: https://gitee.com/hubertshelley/smart7-orm


