diff --git a/models/mysql.py b/models/mysql.py index 218f912..1134bb8 100644 --- a/models/mysql.py +++ b/models/mysql.py @@ -17,5 +17,6 @@ pool = PooledDB( user=MYSQL_USER, password=MYSQL_PASS, database=MYSQL_NAME, - charset='utf8mb4' + charset='utf8mb4', + cursorclass=pymysql.cursors.DictCursor, ) diff --git a/routers/img.py b/routers/img.py index 5a82b12..407300a 100644 --- a/routers/img.py +++ b/routers/img.py @@ -97,12 +97,12 @@ def get_image_type(type:str, id:str, version:str, ext:str): if os.path.exists(img_path): return Response(content=open(img_path, 'rb').read(), media_type=f"image/{ext}") if type == 'ad' or type == 'article' or type == 'article_attribute': - count = cursor.execute(f"SELECT * FROM `web_{type}` WHERE `id`={id}") + count = cursor.execute(f"SELECT image FROM `web_{type}` WHERE `id`={id}") img = cursor.fetchone() if img is None: print('图片不存在:', count) return Response('图片不存在', status_code=404) - url = img['image'] + url = img[0] elif type == 'url': id = unquote(id, 'utf-8') id = id.replace(' ','+')