4
import MySQLdb
name="XYZ"
number=(256, 34576312114897154715004917944343995880721156274004613128261928143013598386679L)
db=MySQLdb.Connect("localhost","root","12345","phone")
cursor=db.cursor()
sql= ("""INSERT INTO phonebook(number, Mobile) VALUES(%s,%s)""" , name,number)
cursor.execute(sql)
db.commit()
db.close()

"Failed processing format-parameters; %s" % err) mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python 'tuple' cannot be converted to a MySQL type

1 Answer 1

2

Your sql variable is a tuple

sql= ("""INSERT INTO phonebook(number, Mobile) VALUES(%s,%s)""" , name,number)

So when it try to execute, cursor.execute(sql) (where sql is tuple) it give error Python 'tuple' cannot be converted to a MySQL type

Please use string.

sql = """INSERT INTO phonebook(number, Mobile) VALUES(%s,%s)""" % (name,number)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.