Another MySQL Problem

Victor Subervi victorsubervi at gmail.com
Sun Dec 13 13:22:36 EST 2009


Hi;

mysql> truncate tem126072414516;
Query OK, 0 rows affected (0.00 sec)

Then I run a script:

  if whatDo == 'insert':
    try:
      sql = 'insert into %s (ProdID, Quantity) values ("%s", "%s");' %
(tmpTable, prodid, quantity)
      print sql
      cursor.execute(sql)

that runs this (printed out) sql insert statement:

insert into tem126072832767 (ProdID, Quantity) values ("2", "2");

But then this...

mysql> select * from tem12607282453 t join products p on t.ID=p.ID;
Empty set (0.00 sec)

mysql> insert into tem126072829782 (ProdID, Quantity) values ("2", "2");
ERROR 1062 (23000): Duplicate entry '2' for key 2

I have to manually truncate the table to manually insert it, and then it
works. But programmatically, it doesn't insert...but it apparently inserts
something, or it wouldn't throw the duplicate entry error. Where is the
problem?
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091213/b7d2d88c/attachment.html>


More information about the Python-list mailing list