fix: Update databases package version

Update databases package with compatiple sqlAlcehemy

Change-Id: If4a91e38d45a1a90ed27e9f4c6303955c07e83d8
This commit is contained in:
resitdemir 2024-05-22 08:18:53 +00:00
parent 42567b8b1c
commit ce7d977df4
2 changed files with 8 additions and 8 deletions

View File

@ -4,8 +4,8 @@ pydantic<=1.10.0 # MIT
uvicorn<=0.17.6 # BSD License (3 clause)
gunicorn>=20.1.0 # MIT
python-jose<=3.3.0 # MIT
databases<=0.8.0 # BSD License (3 clause)
aiomysql<=0.1.1 # MIT
databases>=0.9.0 # BSD License (3 clause)
aiomysql>=0.2.0 # MIT
aiosqlite<=0.17.0 # MIT
loguru<=0.5.3 # MIT
PyYAML>=5.4.1 # MIT

View File

@ -18,7 +18,7 @@ import time
from functools import wraps
from typing import Any
from sqlalchemy import delete, func, insert, select, update
from sqlalchemy import delete, func, insert, select
from skyline_apiserver.types import Fn
@ -41,7 +41,7 @@ def check_db_connected(fn: Fn) -> Any:
async def check_token(token_id: str) -> bool:
count_label = "revoked_count"
query = (
select([func.count(RevokedToken.c.uuid).label(count_label)])
select(func.count(RevokedToken.c.uuid).label(count_label))
.select_from(RevokedToken)
.where(RevokedToken.c.uuid == token_id)
)
@ -76,7 +76,7 @@ async def purge_revoked_token() -> Any:
@check_db_connected
async def list_settings() -> Any:
query = select([Settings])
query = select(Settings)
db = DB.get()
async with db.transaction():
result = await db.fetch_all(query)
@ -86,7 +86,7 @@ async def list_settings() -> Any:
@check_db_connected
async def get_setting(key: str) -> Any:
query = select([Settings]).where(Settings.c.key == key)
query = select(Settings).where(Settings.c.key == key)
db = DB.get()
async with db.transaction():
result = await db.fetch_one(query)
@ -97,7 +97,7 @@ async def get_setting(key: str) -> Any:
@check_db_connected
async def update_setting(key: str, value: Any) -> Any:
get_query = (
select([Settings.c.key, Settings.c.value]).where(Settings.c.key == key).with_for_update()
select(Settings.c.key, Settings.c.value).where(Settings.c.key == key).with_for_update()
)
db = DB.get()
async with db.transaction():
@ -106,7 +106,7 @@ async def update_setting(key: str, value: Any) -> Any:
query = insert(Settings)
await db.execute(query, {"key": key, "value": value})
else:
query = update(Settings).where(Settings.c.key == key)
query = insert(Settings).values(key=key, value=value)
await db.execute(query, {"value": value})
result = await db.fetch_one(get_query)