我尝试过使用几种方法将数据插入mysql数据库,但都出现了错误: 在第一种方法中:
sql = ('''Insert into lgemployees (EmpID,Name,Gender,DOB,Address,PhoneNumber,Email)
VALUES (%d,$s,$s,$s,$s,$d,$s)''', (eid, name, gen, dob, add, mob, email))
mycursor.execute(sql)
mycursor.commit()
此方法中的错误:
'tuple' object has no attribute 'encode'
第二种方法:
sql = "Insert into lgemployees (EmpID,Name,Gender,DOB,Address,PhoneNumber,Email) VALUES(?,?,?,?,?,?,?,)"
val = (eid, name, gen, dob, add, mob, email)
mycursor.execute(sql, val)
mycursor.commit()
此方法中的错误:
"Not all parameters were used in the SQL statement")
mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement
从我这一头开始,我已经解决了很多麻烦,但是运气不好。任何人都可以帮助我,因为我哪里错了或什么可以是一个很好的选择,插入数据到mysql从python
我不知道你的错误是在哪里,但我测试了这个代码,它的工作
您的代码抛出此错误是因为其中一个参数为空或其格式无法读取
相关问题 更多 >
编程相关推荐