Linux Directory Structure
· 5 min read







FastAPI framework, high performance, easy to learn, fast to code, ready for production
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
Python 安装包中没有集成 MySQL 数据库驱动,而 ORM 框架 SQLAlchemy 依赖于数据库驱动,所以第一步需要安装 MySQL 驱动。在 Python 3.x 中推荐使用 PyMySQL,其遵循 Python 数据库 API v2.0 规范,并完全使用 Python 代码实现。
pip install pymysql
示例目录结构如下:
.
├── sql_app
│ ├── __init__.py
│ ├── database.py
│ ├── models.py
│ ├── schemas.py
│ ├── crud.py
│ ├── routers.py
│ └── sql_app.db
└── main.py

枚举(Enum)类型经常被用于取值在一定范围内的场景,比如一周只能有七天,角色权限设计等。枚举类型变量使用enum字段来定义,枚举成员的值可以是数字或者字符串,并且枚举成员是只读的。
枚举按照类型划分,主要分为以下三种: