feat: 完成基本功能

This commit is contained in:
Rock Chin
2022-12-08 12:06:04 +08:00
parent 9ca641a2e5
commit 77ec1c7ff0
5 changed files with 53 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
import time
import pymysql
from pymysql.converters import escape_string
import config
@@ -61,12 +62,13 @@ class DatabaseManager:
insert into `sessions` (`name`, `type`, `number`, `create_timestamp`, `last_interact_timestamp`, `prompt`)
values ('{}', '{}', {}, {}, {}, '{}')
""".format("{}_{}".format(subject_type, subject_number), subject_type, subject_number, create_timestamp,
last_interact_timestamp, prompt))
last_interact_timestamp, escape_string(prompt)))
else:
self.cursor.execute("""
update `sessions` set `last_interact_timestamp` = {}, `prompt` = '{}'
where `type` = '{}' and `number` = {} and `create_timestamp` = {}
""".format(last_interact_timestamp, prompt, subject_type, subject_number, create_timestamp))
""".format(last_interact_timestamp, escape_string(prompt), subject_type,
subject_number, create_timestamp))
# 记载还没过期的session数据
def load_valid_sessions(self) -> dict: