当我使用psycopg2运行以下代码时:
cur.execute(
"""INSERT INTO logmsg (msg_type, file, msg) VALUES %s;""",
["Error", str(file), str(sys.exc_info()[0])])
我收到以下错误:
TypeError:并非在格式化字符串时转换所有参数
有人可以帮我吗?
[VALUES
需要括在方括号中的值的列表:
cur.execute(
"""INSERT INTO logmsg (msg_type, file, msg) VALUES (%s, %s, %s);""",
["Error", str(file), str(sys.exc_info()[0])])
不要忘记提交事务。