09 2023 档案
FastAPI.9
摘要:# Alembic ## 一、什么是Alembic 1. Alembic是一种用于数据迁移和版本控制的工具,特别适用于Python编写的数据库应用程序。它允许你按照预定的数据库模型定义,在不丢失现有数据的情况下进行数据库模式的更改。 2. Alembic的一些关键概念和功能 ``` 1. 迁移文件(
阅读全文
FastAPI.8
摘要:# FastAPI之连接数据库 ### 1.databases.py ```python from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarat
阅读全文
FastAPI.7
摘要:# FastAPI的Post请求 ### 1.接受query参数 ```python from fastapi import FastAPI, Query @app.post('/login') def login(username: str = Query(...), password: str
阅读全文
FastAPI.6
摘要:## FastApi用pillow生成随机四位数字验证码图片 1. 导入模块 ```python import random from fastapi import FastAPI,Response from PIL import Image, ImageDraw, ImageFont from i
阅读全文
FastAPI.5
摘要:# FastAPI中async def 和def的区别 ### 在FastAPI中,async def和def之间具有一些区别。 1. `异步支持`: async def定义的函数可以是异步函数,它们可以使用await关键字暂停执行并等待其他协程完成。而def定义的函数是同步函数,它们的执行是顺序的
阅读全文