Re: MySQLdb UPDATE does nothing

2005-09-16 Thread Steve Horsley
Magnus Lycka wrote: > Steve Horsley wrote: >> Or, as I found out yesterday, cursor.execute('commit') afterwards. > > The correct way to do it is to close the cursor object, and > then do "db.commit()". Don't rely on a cursor object to work > across transaction boundries! > > See e.g. www.thinkwar

Re: MySQLdb UPDATE does nothing

2005-09-16 Thread Magnus Lycka
Steve Horsley wrote: > Or, as I found out yesterday, cursor.execute('commit') afterwards. The correct way to do it is to close the cursor object, and then do "db.commit()". Don't rely on a cursor object to work across transaction boundries! See e.g. www.thinkware.se/epc2004db/epc04_mly_db.pdf and

Re: MySQLdb UPDATE does nothing

2005-09-15 Thread Steve Horsley
Rowdy wrote: >> A similar question was asked back in July, someone posted this: > > > If it's any help, using > > cursor.execute("set autocommit = 1") > > before doing anything else works nicely unless you actually need > transactions. > Or, as I found out yesterday, cursor.execute('comm

Re: MySQLdb UPDATE does nothing

2005-09-15 Thread Rowdy
John Moore wrote: > Hi, > > I normally work with Java but I'm interested in using Python as well, > particularly for little tasks like doing some massaging of data in a > MySQL database. Below is my first attempt. I'm sure it's inelegantly > written, but my main concern is that the UPDATE sql d

Re: MySQLdb UPDATE does nothing

2005-09-15 Thread Simon Brunning
On 9/15/05, John Moore <[EMAIL PROTECTED]> wrote: > I tried that, but got this: > > Traceback (most recent call last): > File "moddb.py", line 31, in ? > cursor.commit() > AttributeError: 'Cursor' object has no attribute 'commit' Oops. I should have said connection.commit(). Posting before

Re: MySQLdb UPDATE does nothing

2005-09-15 Thread David Wilson
>> sql="UPDATE product_attribute SET index_column = "+str(index)+" WHERE id = >> "+str(record2[0]) >> .. >> cursor.execute(sql) To allow the DB-API adaptor to correctly take care of value conversion and SQL escaping for you, this should be written as: cursor.execute("UPDATE product_attribute SET

Re: MySQLdb UPDATE does nothing

2005-09-15 Thread Simon Brunning
On 9/15/05, John Moore <[EMAIL PROTECTED]> wrote: > ... my main concern is that the UPDATE sql doesn't actually > work, and I can't understand why. You probable need to commit your changes. Try a cursor.commit() call. If all the changes make up one logical transaction, do the commit at the end of

MySQLdb UPDATE does nothing

2005-09-15 Thread John Moore
Hi, I normally work with Java but I'm interested in using Python as well, particularly for little tasks like doing some massaging of data in a MySQL database. Below is my first attempt. I'm sure it's inelegantly written, but my main concern is that the UPDATE sql doesn't actually work, and I c