📢 2022 年 10 月 29 日, 更新提醒:
- 我想覆盖以前所有的提交, 这是一个让我难以决定的事实, 因为在所有功能的提交说明中, 有很多让 人们误解的东西, 对于关注提交信息的人来讲, 存在很多误导性, 并且我是一个高度强迫症患者, 我没有 理由拒绝此次决定
- 将升级一些核心库: fastapi, pydantic, sqlalchemy... 为了保持兼容性, 你可能必须同步 仓库状态来保持他们的全局可用性
- 对以前复刻,点星和下载的人们说声抱歉, 如果你直接使用它作为了基础开发环境, 那可能会对你造成 不必要的困扰, 我也不建议将它直接作为你的基础开发环境, 但是作为入门参考, 它应该会给你一些启发, 并且这也是此仓库的主要目的
🏁 我将在后面的空闲时间对现有维护分支进行逐一更新, 这可能是一个漫长的过程, 在分支完成更新前, 它的原有分支提交不会被覆盖, 仍然可以从中获取部分参考, 但作为旧的内容, 我个人不提倡; 在所有现有 维护分支更新完毕后, 考虑将它们以发版的形式作为初始标记, 预计年前完成🙏
fastapi + sqlalchemy + alembic + aiomysql + aioredis
📢: 含 redis 邮箱验证码登录
fastapi + sqlalchemy + alembic + aiomysql + aioredis + APScheduler
📢: 在 master 分支基础上扩展, 加入 APScheduler 定时任务
✨: 删除了邮箱验证码登录, 新增了图片验证码登录
❗:很遗憾,此分支已停止维护,仅作为异步图形验证码登陆保留
fastapi + sqlalchemy + alembic + aiomysql + aioredis + APScheduler
📢: 在 master 分支基础上扩展,对普通 CRUD 操作进行封装,加入 APScheduler 定时任务
fastapi + sqlalchemy + alembic + aiomysql + aioredis + APScheduler + pycasbin
📢: 在 async-CRUDBase 分支基础上扩展,加入 RBAC 鉴权
fastapi + sqlalchemy + alembic + pymysql + redis
📢: 含 redis 图片验证码登录
fastapi + sqlalchemy + alembic + pymysql + redis + APScheduler
📢: 在 sync 分支基础上扩展,对普通 CRUD 操作进行封装,加入 APScheduler 定时任务
fastapi + sqlalchemy + alembic + pymysql + redis + APScheduler + pycasbin
📢: 在 sync-CRUDBase 分支基础上扩展,加入 RBAC 鉴权
#全部分支:
git clone https://gitee.com/wu_cl/fastapi_sqlalchemy_mysql.git
#指定分支:
git clone -b 分支名 https://gitee.com/wu_cl/fastapi_sqlalchemy_mysql.git
⚠️ : 此过程请格外注意端口占用情况, 特别是 8000, 3306, 6379...
-
安装依赖
pip install -r requirements.txt
-
创建数据库 fsm, 选择 utf8mb4 编码
-
查看 backend/app/core/conf.py 配置文件, 检查并修改数据库配置信息
-
执行数据库迁移 alembic
cd backend/app/ # 生成迁移文件 alembic revision --autogenerate # 执行迁移 alembic upgrade head
-
安装启动 redis
-
查看 backend/app/core/conf.py 配置文件, 检查并修改 redis 配置信息
-
执行 backend/app/main.py 文件启动服务
-
在 docker-compose.yml 文件所在目录下执行一键启动命令
docker-compose up -d --build
-
等待命令自动执行完成
执行 backend/app/init_test_data.py 文件
结构树基本大致相同,详情请查看源代码
├── backend
│ └── app
│ ├── alembic
│ ├── api
│ │ └── v1
│ ├── common
│ ├── core
│ ├── crud
│ ├── database
│ ├── middleware
│ ├── models
│ ├── schemas
| |—— static
│ ├── test
│ └── utils
├── LICENSE
├── README.md
└── requirements.txt