Environment: Win Xp Pro SP2
Mysql-python version: 1.2.0
python version: 2.4.2.msi
mysql version: both 4.1.15 and 5.0.18 FAIL
BUG Description: when updating tables the last table
in the program NEVER HAS ITS RECORDS COMMITTED. if the
program has 2 tables updated only the first table will
have its records written and committed. similarly if 3
tables are updated then the first two will be updated
correctly and the last will be in error (i tried the
program below - which uses just two tables but
suffices to recreate the problem - with five tables,
again the first 4 were ok but the last table mentioned
had no committed records, so at least the bug is
consistent)
note: because its always the last file thats in error
i tried commenting out the very last line (conn.close
()) but this DIDNT solve the problem.
if you access mysql from the command line the last
table you were trying to update/insert (assuming empty
file to begin with) will show "empty set" after the
inserts should have taken place.
anyway type the program in below as is "it uses
mysql's builtin in test database so there's no
problems there and it drops/recreates the test files
each time so you can just keep running it to see the
results
cheers and... good luck
P.S. i'm trying to find a workaround but no joy at the
moment
lloyd (tanabataman@hotmail.com - 20 jan 2006)
--- START OF PROGRAM ---
import MySQLdb
conn = MySQLdb.connect(
host='localhost',
user='root',
passwd='root',
db='test')
sql = 'drop table if exists t1,t2;'
cursor = conn.cursor()
cursor.execute(sql)
cursor.close()
sql = 'create table t1 (testrecord char(10));'
cursor = conn.cursor()
cursor.execute(sql)
cursor.close()
sql = 'insert into t1 values("iamarecord");'
cursor = conn.cursor()
cursor.execute(sql)
cursor.close()
sql = 'select * from t1;'
cursor = conn.cursor()
cursor.execute(sql)
rows = cursor.fetchall()
print '\ncontents of t1...\n'
for row in rows:
print row
cursor.close()
sql = 'create table t2 (testrecord char(10));'
cursor = conn.cursor()
cursor.execute(sql)
cursor.close()
sql = 'insert into t2 values("iamarecord");'
cursor = conn.cursor()
cursor.execute(sql)
cursor.close()
sql = 'select * from t2;'
cursor = conn.cursor()
cursor.execute(sql)
rows = cursor.fetchall()
print '\ncontents of t2...\n'
for row in rows:
print row <= record prints out but is not committed
cursor.close()
conn.close()
--- END OF PROGRAM ---
Logged In: YES
user_id=71372
conn.commit() before conn.close() so we can both have some joy.