From bd9dac23be32d7f6c22a9c567a8484ddeb2a942d Mon Sep 17 00:00:00 2001 From: chenweijia Date: Tue, 13 Aug 2024 14:57:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20api=E7=A4=BA=E4=BE=8B=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=93=8D=E4=BD=9C=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/conf-dev.ini | 2 +- src/api/example.py | 7 +++++++ start.bat | 2 +- start.sh | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/conf/conf-dev.ini b/conf/conf-dev.ini index 47bcae3..6361f25 100644 --- a/conf/conf-dev.ini +++ b/conf/conf-dev.ini @@ -4,7 +4,7 @@ lifetime_seconds=3600 [mysql] username=root -password=Chenweijia113! +password=123456 host=127.0.0.1 port=3306 database=test diff --git a/src/api/example.py b/src/api/example.py index 12a6471..bf6115b 100644 --- a/src/api/example.py +++ b/src/api/example.py @@ -5,6 +5,8 @@ import aioredis from fastapi import APIRouter, Depends, Query from fastapi.security import OAuth2PasswordBearer from fastapi_plugins import depends_redis +from fastapi_sqlalchemy import db +from sqlalchemy.sql import text from pydantic import BaseModel from src.service.example import get_user_by_id @@ -59,6 +61,11 @@ async def get_user_list_pages(page: int = Query(..., description="当前页码") res = response(data=data, message="Ok!") return res +# 数据库查询 +@router.get('/get_db_version') +async def get_db_version(): + result = db.session.execute(text("SELECT version()")).first() + return dict(result=result.tuple()[0]) # Redis 缓存查询 @router.get("/ping") diff --git a/start.bat b/start.bat index cc75040..6297c36 100644 --- a/start.bat +++ b/start.bat @@ -1,2 +1,2 @@ set FAST_API_ENV=dev -uvicorn main:fast_api_app --reload --host 0.0.0.0 --port 21021 \ No newline at end of file +uvicorn main:fast_api_app --reload --host 0.0.0.0 --port 8088 \ No newline at end of file diff --git a/start.sh b/start.sh index 7c9b752..76869b1 100755 --- a/start.sh +++ b/start.sh @@ -1,2 +1,2 @@ export FAST_API_ENV=dev -uvicorn main:fast_api_app --reload --host 0.0.0.0 --port 21021 \ No newline at end of file +uvicorn main:fast_api_app --reload --host 0.0.0.0 --port 8088 \ No newline at end of file