Giter VIP home page Giter VIP logo

fastapi_sqlalchemy_mysql's Introduction

FastAPI SQLAlchemy Architecture

作为 FastAPI 框架的一个基础项目,基于 python3.10 开发

特征

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

使用

Warning

此过程请格外注意端口占用情况, 特别是 8000, 3306, 6379...

1: 传统

  1. 安装依赖项

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

  3. 安装启动 redis

  4. backend/app/ 目录下创建一个 .env 文件

    cd backend/app/
    touch .env
  5. 复制 .env.example.env

    cp .env.example .env
  6. 数据库迁移 alembic

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

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


2: docker

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

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

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

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

互动

有且仅有当前一个频道,请注意辨别真伪

直链跳转
Telegram

赞助

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

Wechat Alipay 0x40D5e2304b452256afD9CE2d3d5531dc8d293138
微信 支付宝 ERC20

许可证

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

fastapi_sqlalchemy_mysql's People

Contributors

wu-clan avatar dependabot[bot] 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.