I have a simple table
******************
MId | Title
1 | pqr
2 | abc
******************
now the code which i have written to append data to table is
import MySQLdb
db = MySQLdb.connect("localhost", "root", "a", "Project")
cursor = db.cursor()
sql = "INSERT INTO Project.Movie(MId, Title) VALUES(%d, %s)" % (21,'aman')
cursor.execute(sql)
But the above code generates error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 159, in execute
query = query % db.literal(args)
TypeError: %d format: a number is required, not str
I have just passed number and not in quotes then why is there an error ?
execute()