I'm having trouble getting my python scripts to insert into a mysql database. I'm able to do other commands successfully such as adding or dropping tables, selecting items from tables but inserting into tables isn't working. I can manually insert but the script won't do it.
I have an entry field for a last name and am using .get() to grab the data. If I enter the name 'Jones' into the field and submit it, I get this error:
OperationalError: (1054, "Unknown column 'Jones' in 'field list'")
If I move the quotes around I won't get an error message but it also won't show up in the database.
mysql>INSERT INTO persons (lname) VALUES ("Jones"); Query OK, 1 row affected (0.36 sec)
test4=win4a.get() # Last name cursor.execute("INSERT INTO persons (lname) VALUE (%s)"% (test4))
If tried this which gets no errors but also doesn't insert:
cursor.execute("INSERT INTO persons (lname) VALUE ('%s')"% (test4))
Even if I change it to the following, I will still get the same error message:
cursor.execute("INSERT INTO persons (lname) VALUE ('Jones')")
My script is using the right database & tables.