【发布时间】:2021-04-08 12:33:06
【问题描述】:
我已尝试此代码,但收到 1064 错误。
x_1=**********
t_2=(x_1)
cursor.execute('insert into informations' '(password)' 'values (%s)',t_2)
【问题讨论】:
标签: python mysql mysql-connector-python
我已尝试此代码,但收到 1064 错误。
x_1=**********
t_2=(x_1)
cursor.execute('insert into informations' '(password)' 'values (%s)',t_2)
【问题讨论】:
标签: python mysql mysql-connector-python
cursor.execute('insert into informations (password) values (?)', (x_1,))
会是更好的语法。
只有一个字符串,包括整个语句,并使用问号作为要插入的值的占位符。
最重要的是将单个值定义为元组。
【讨论】: