/fastapi-sqlmodel-starter

One of the best scaffolding in the PyWeb field.

Primary LanguagePythonMIT LicenseMIT

FastAPI SQLModel Starter (Fss)

logo

GitHub License PyPI - Python Version CI Codecov Read the Docs

简体中文 | English

PyWeb领域最好用的脚手架之一。

特性

  • ⚡ 开箱即用, 完全实现中间件零依赖
    • 默认使用Sqlite, 也可自由切换PostgreSQL、MySQL
    • 默认使用文件缓存, 支持切换为Redis
  • 🚢 开启Python操作数据库表结构的新体验
  • 🚀 内置单表常见操作, 简化ORM操作
  • 🎨 丰富插件机制
    • Jwt安全认证
    • 访问限流
    • Ip黑名单
  • 🐋 完备容器化解决方案
    • Docker
    • Docker-compose
    • Kubernetes
  • ✅ 基于GitHub Actions的CI (持续集成) 和 CD (持续交付)

文档

设置一个虚拟环境

这部分是可选的,但可能对新学 Python 的用户有用。虚拟环境设置

快速开始

  1. 克隆代码
git clone https://github.com/tyvekzhang/fastapi-sqlmodel-starter.git
cd fastapi-sqlmodel-starter
  1. 安装 Poetry并下载依赖
  • 通过conda虚拟环境安装, 如果安装了conda的话
    conda install poetry -y
    poetry install
  • 或者通过pip安装
    pip install poetry -i https://mirrors.aliyun.com/pypi/simple/
    poetry install
  1. 数据库迁移
cd fss && alembic upgrade head
  1. 启动
python apiserver.py
  1. 交互式文档地址: http://127.0.0.1:9010/docs
  2. 恭喜你, 运行成功. 接口访问前需创建用户, 并进行认证
  3. 可以随时按CTRL+C停止运行

许可证

FastapiSqlmodelStarter 采用 MIT 许可证开源。