predecessor:
MySQL Table created via: CREATE TABLE table(Id INT PRIMARY KEY NOT NULL, Param1 VARCHAR(50))
Function:
.execute("INSERT INTO table VALUES(%d,%s)", (int(id), string)
Exit:
TypeError: %d format: a number is required, not a str
I am not sure what is going on here or why I cannot execute the command. This uses MySQLdb in Python. .execute is executed on the cursor object.
EDIT:
Question: Python MySQLdb releases (Error like:% d format: number required, not str) says that you should use %s for all fields. Why could this be? Why does this command work?
.execute("INSERT INTO table VALUES(%s,%s)", (int(id), string)
python mysql mysql-python
Matt stokes
source share