Where does MySQLdb put inserted data?
F.R.
anthra.norell at bluewin.ch
Fri Oct 4 06:05:17 EDT 2013
On 10/04/2013 09:38 AM, F.R. wrote:
> 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)
>
Thank you Chris, thank you Steven,
The suggestion to switch to PostgreSQL isn't lost on me. I have it
installed, but have been putting off the change, apprehensive of getting
slowed down by many annoying side effects for some time to come. This
may be the moment . . .
Off list? MySQL is. MySQLdb is not. Before I know which of the two
is the culprit, I don't know whether I'm off list or not and take the
risk, prepared to beg pardon if I am.
Frederic
More information about the Python-list
mailing list