上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 201 下一页
摘要: 一,报错信息: sqlalchemy.exc.StatementError: (builtins.ValueError) Value 123 is not None, True, or False 二,原因: 这个报错的根本原因在于:你把数据库中某个定义为布尔类型(Boolean / BOOL)的字 阅读全文
posted @ 2026-06-12 10:53 刘宏缔的架构森林 阅读(8) 评论(0) 推荐(0)
摘要: 一,报错信息: RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods 原因: 这个错误在 FastAPI(或者更准确地说是底层使用的 PyM 阅读全文
posted @ 2026-06-12 10:53 刘宏缔的架构森林 阅读(12) 评论(0) 推荐(0)
摘要: 一,创建相应的数据库: 二,安装sqlalchemy和mysql驱动 $ pip install sqlalchemy aiomysql pydantic 三,代码 database.py # app/core/database.py from sqlalchemy.orm import sessi 阅读全文
posted @ 2026-06-12 10:53 刘宏缔的架构森林 阅读(16) 评论(0) 推荐(0)
摘要: 一,目录结构 二,代码 main.py # main.py from fastapi import FastAPI from app.api import products, users, account from app.core.exceptions import register_except 阅读全文
posted @ 2026-06-12 10:53 刘宏缔的架构森林 阅读(6) 评论(0) 推荐(0)
摘要: 一,代码: 目录结构: header.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{{ title }}</title> </head> <body> <div style="width:100 阅读全文
posted @ 2026-06-12 10:53 刘宏缔的架构森林 阅读(3) 评论(0) 推荐(0)
摘要: 一,选择结构 python代码: # app/api/users.py from fastapi import APIRouter, Depends from starlette.requests import Request from starlette.templating import Jin 阅读全文
posted @ 2026-06-12 10:52 刘宏缔的架构森林 阅读(3) 评论(0) 推荐(0)
摘要: 一,安装jinja2模板引擎 $ pip install jinja2 python-multipart 创建模板文件目录templates,并把模板文件放到此目录下 二,代码: html代码: <!DOCTYPE html> <html lang="en"> <head> <meta charse 阅读全文
posted @ 2026-06-12 10:52 刘宏缔的架构森林 阅读(3) 评论(0) 推荐(0)
摘要: 一,验证签名的作用: 在 FastAPI 中,使用中间件进行接口签名验证(Signature Verification)能有效防止接口被篡改和防重放攻击。你可以通过继承 BaseHTTPMiddleware 来实现全局的请求拦截与签名校验。 签名生成规则(客户端与服务端约定) 通常签名的生成包含三个 阅读全文
posted @ 2026-06-12 10:52 刘宏缔的架构森林 阅读(15) 评论(0) 推荐(0)
摘要: sqlalchemy 指定值为null 在 SQLAlchemy 中,将字段值指定为 null 取决于使用场景(如新增数据、更新数据或查询条件)。在 Python 中,请直接使用 None,SQLAlchemy 会将其自动转换为 SQL 的 NULL。 以下是不同场景下的具体写法: 1. 新增数据 阅读全文
posted @ 2026-06-10 15:23 刘宏缔的架构森林 阅读(6) 评论(0) 推荐(0)
摘要: 一,例子: migrations目录实际上是加入到了gitignore中的 二,这是因为该文件在被加入 .gitignore 之前,就已经被 Git 追踪(Tracked)并提交到版本库中了。 .gitignore 文件只对未追踪(Untracked)的文件有效。一旦文件已经存在于 Git 仓库中, 阅读全文
posted @ 2026-06-10 15:23 刘宏缔的架构森林 阅读(13) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 201 下一页