Where does MySQLdb put inserted data?

F.R. anthra.norell at bluewin.ch
Fri Oct 4 03:38:41 EDT 2013


Hi,
     As of late clipboard pasting into a terminal sometimes fails (a 
known bug, apparently), I use MySQLdb to access MySQL tables. In general 
this works just fine. But now I fail filling a new table. The table 
exists. "mysql>EXPLAIN new_table;" explains and "root at blackbox-one:/# 
sudo/find / -name 'new_table*'" finds "/var/lib/mysql/fr/new_table.frm". 
So I do "cursor.executemany ('insert into new_table values (%s)' % 
format, data)". No error occurs and "cursor.execute ('select * from 
new_table;')" returns the number of records read, and "cursor.fetchall 
()" returns all new records. All looks fine, but "mysql>SELECT * FROM 
new_table;" produces an "Empty set" and "sudo find / -name 'new_table*" 
still finds only the format file, same as before.
     Could it have to do with COMMIT. I believe I am using ISAM tables 
(default?) and those don't recognize undo commands, right?. Anyway, an 
experimental "cursor.execute ('COMMIT')" didn't make a difference. It 
looks like MySQLdb puts the data into a cache and that cache should be 
saved either by the OS or by me. Strange thing is that this is one freak 
incident in an almost daily routine going back years and involving 
thousands of access operations in and out acting instantaneously. I seem 
to remember a similar case some time ago and it also involved a new 
empty table.

Thanks for hints

Frederic



mysql> select version()
     -> ;
+-------------------------+
| version()               |
+-------------------------+
| 5.5.31-0ubuntu0.12.04.1 |
+-------------------------+
1 row in set (0.00 sec)




More information about the Python-list mailing list