[pysqlite] [3.6.3-r1] Row not updated?

Fred <[email protected]> Thu, 20 Nov 2008 10:57:10 +0100
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Hello

I can't figure out why the SQLite database is not updated with the 
following code which I use to download information on companies from 
web servers. Maybe some fresh eyes can spot the error :-)

1. Here's the output:
======
C:\>download.py
[...]
UPDATE ape SET nombre=67 WHERE code='123'
======
C:\>sqlite3.exe mydb.sqlite
sqlite> select * from ape where code='123';
1|123|Some label|
======

=> The last field should contain 67!

2. Here's the stripped-down code:
======
connection=apsw.Connection("mydb.sqlite")
cursor=connection.cursor()

sql = 'SELECT code,label FROM mytable'
rows=list(cursor.execute(sql))
for id in rows:
	#fetch web page, and extract relevant information

	m = found.search(response)
	if m:
		try:
			sql = "UPDATE ape SET nombre=%s WHERE code='%s'" % (m.group(1),ape)
			print sql
			cursor.execute(sql)
		except:
			print "Error: " + sql
			break

		matches = companies.finditer(response)
		cursor.execute("BEGIN")
		for match in matches:
			lastcompany = match.group(1)
			print "Found %s " % lastcompany
			sql = 'INSERT INTO companies (code,id) VALUES ("%s","%s")' % 
(ape,lastcompany)
			cursor.execute(sql)
		cursor.execute("COMMIT")
				
	connection.close(True)
======

Is it my code, or some internal feature of APSW that could explain 
why the UPDATE statement isn't actually executed?

Thank you.