TypeError: not all arguments converted during string formatting in psycopg2
TypeError: not all arguments converted during string formatting in psycopg2
当我使用 psycopg2 运行 下面的代码时:
cur.execute(
"""INSERT INTO logmsg (msg_type, file, msg) VALUES %s;""",
["Error", str(file), str(sys.exc_info()[0])])
我收到以下错误:
TypeError: not all arguments converted during string formatting
有人可以帮我解决这个问题吗?
VALUES
需要用方括号括起来的值列表:
cur.execute(
"""INSERT INTO logmsg (msg_type, file, msg) VALUES (%s, %s, %s);""",
["Error", str(file), str(sys.exc_info()[0])])
不要忘记提交事务。
当我使用 psycopg2 运行 下面的代码时:
cur.execute(
"""INSERT INTO logmsg (msg_type, file, msg) VALUES %s;""",
["Error", str(file), str(sys.exc_info()[0])])
我收到以下错误:
TypeError: not all arguments converted during string formatting
有人可以帮我解决这个问题吗?
VALUES
需要用方括号括起来的值列表:
cur.execute(
"""INSERT INTO logmsg (msg_type, file, msg) VALUES (%s, %s, %s);""",
["Error", str(file), str(sys.exc_info()[0])])
不要忘记提交事务。