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