0
c.execute("""DELETE FROM data
WHERE user = %s AND machine = %s""" , (user, machine))

I have two variables that were sent with get (technically they were machine+user, and then I split the variable based on the plus), who were then respectively assigned to the variables machine and user.

Theoretically this script should work, correct? What am I doing incorrectly? It does not delete the record I wish it would, or any at all.

Steven Matthews
  • 9,705
  • 45
  • 126
  • 232
  • That part of it looks fine - have you checked that `user` and `machine` are what you expect, and are the same as in the database? – Daniel Roseman Oct 28 '11 at 13:42
  • 1
    Have you called `connection.commit()` to commit the transaction? (Needed for INNODB tables, though not MyISAM tables). – unutbu Oct 28 '11 at 13:44
  • While you're at it, a) verify that c is what it should be and b) test it with a fully hard-coded query string c) check the error returned from c.execute – Scott Hunter Oct 28 '11 at 13:46
  • To debug this, you might also want to print out `c._executed`, which will show you the string that was sent to the MySQL server. Then test that string at the `mysql>` command-line prompt. Does it work as you expect? – unutbu Oct 28 '11 at 13:47

1 Answers1

0

See my data won't go away. Hint: commit() needed

Ocaso Protal
  • 19,362
  • 8
  • 76
  • 83