I have a table with 4 columns using an auto incrementing primary key and 3 strings.
The below code is what I'm using in python to add a row.
cursor = conn.cursor()
cursor.execute('INSERT INTO details (subject, due, description) VALUES("%s", "%s", "%s")' % (subject, due, description))
cursor.close
conn.close
This appears to run fine in Python, no errors come up but when I check if its been entered into the table, it does not appear. However, If I manually go an add an entry, the auto increment has skipped a value for every time I ran the program?
+----+-----------+--------+----------------------------+
| id | subject | due | description |
+----+-----------+--------+----------------------------+
| 1 | C00000 | 000000 | abc |
| 2 | c11111 | 111111 | abc |
| 7 | c11111 | 111111 | abc |
| 10 | c11111 | 111111 | abc |
+----+-----------+--------+----------------------------+
4 rows in set (0.00 sec)
Adding a print statement for the same code that is executed and then copying it directly into the mysql command line works correctly. Example of printout below.
INSERT INTO details (subject, due, description) VALUES("ABCDEFG", "211111", Do something")
Using Python 2.6.2 and Server version: 5.1.37-community MySQL Community Server (GPL)