【发布时间】:2023-03-25 09:47:02
【问题描述】:
我想将我的日志保存在 mysql 数据库中。所以我创建了这个函数来放入一个字符串,然后该函数将字符串格式化为 sql 注入并执行它。但总是失败。
功能:
def log(string):
sqlFormula = f'INSERT INTO logs (log) VALUES (%s)'
string = f'({string})'
mycursor.execute(sqlFormula, string)
mydb.commit()
【问题讨论】:
-
总是失败是什么意思?失败怎么办?