简体   繁体   English

如何使用 Python 将单个数据插入 Mysql 表中?

[英]How can i insert a single data into a Mysql table using Python?

I have tried this code but i receive the 1064 error.我已经尝试过此代码,但收到 1064 错误。

x_1=**********    
t_2=(x_1)
cursor.execute('insert into informations' '(password)' 'values (%s)',t_2)
cursor.execute('insert into informations (password) values (?)', (x_1,))

would be a better syntax.会是更好的语法。

Just one string including the whole statement and using a question mark as placeholder for the value to insert.只有一个字符串,包括整个语句并使用问号作为要插入的值的占位符。

The most important is to define the single value into a tuple.最重要的是将单个值定义为元组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM