11
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import aiomysql
|
import aiomysql
|
||||||
|
|
||||||
|
from astrbot.api import logger
|
||||||
|
|
||||||
class AsyncMySQL:
|
class AsyncMySQL:
|
||||||
def __init__(self, db_config: dict):
|
def __init__(self, db_config: dict):
|
||||||
@@ -71,6 +72,7 @@ class AsyncMySQL:
|
|||||||
keys = ", ".join(f"`{k}`" for k in data.keys())
|
keys = ", ".join(f"`{k}`" for k in data.keys())
|
||||||
placeholders = ", ".join(["%s"] * len(data))
|
placeholders = ", ".join(["%s"] * len(data))
|
||||||
sql = f"INSERT INTO `{table}` ({keys}) VALUES ({placeholders})"
|
sql = f"INSERT INTO `{table}` ({keys}) VALUES ({placeholders})"
|
||||||
|
logger.info(f"Executing SQL: {sql}")
|
||||||
return await self.execute(sql, tuple(data.values()))
|
return await self.execute(sql, tuple(data.values()))
|
||||||
|
|
||||||
async def update_record(self, table: str, data: dict, where: dict):
|
async def update_record(self, table: str, data: dict, where: dict):
|
||||||
|
|||||||
+1
-1
@@ -2,8 +2,8 @@
|
|||||||
import json
|
import json
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from typing import Optional, Dict, Any, Union, List
|
from typing import Optional, Dict, Any, Union, List
|
||||||
|
|
||||||
from aiohttp import ClientTimeout, ClientSession
|
from aiohttp import ClientTimeout, ClientSession
|
||||||
|
|
||||||
from astrbot.api import logger
|
from astrbot.api import logger
|
||||||
|
|
||||||
class APIClient:
|
class APIClient:
|
||||||
|
|||||||
Reference in New Issue
Block a user