Giter Club home page Giter Club logo

fastapi_sqlalchemy_mysql's Introduction

FastAPI SQLAlchemy MySQL

Static Badge

Tip

此仓库是我们构建的 FastAPI 基础架构便捷版,完整版请查看: fastapi_best_architecture

特征

  • FastAPI
  • Async design
  • Restful API
  • SQLAlchemy 2.0
  • Pydantic 2.0
  • Docker
  • ......

本地开发

  • Python 3.10+
  • Mysql 8.0+
  • Redis 推荐最新稳定版
  1. 安装依赖项

    pip install -r requirements.txt
  2. 创建一个数据库 fsm, 选择 utf8mb4 编码

  3. 安装启动 Redis

  4. 创建一个 .env 文件

    touch .env
    cp .env.example .env
  5. 按需修改配置文件 core/conf.py.env

  6. 数据库迁移 alembic

    # 生成迁移文件
    alembic revision --autogenerate
    
    # 执行迁移
    alembic upgrade head
  7. 执行 main.py 文件启动服务

  8. 浏览器访问: http://127.0.0.1:8000/api/v1/docs


Docker

Warning

默认端口冲突:8000,3306,6379

建议在部署前关闭本地服务:mysql,redis...

  1. 进入 docker-compose.yml 文件所在目录,创建环境变量文件 .env

    cd deploy/docker-compose/
    
    cp .env.server ../../.env
  2. 执行一键启动命令

    docker-compose up -d --build
  3. 等待命令自动完成

  4. 浏览器访问:http://127.0.0.1:8000/api/v1/docs

互动

WeChat / QQ

赞助

如果此项目能够帮助到你,你可以赞助作者一些咖啡豆表示鼓励:☕ Sponsor ☕

许可证

本项目根据 MIT 许可证的条款进行许可

fastapi_sqlalchemy_mysql's People

Contributors

wu-clan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.