MySQL connector issue

Joseph L. Casale jcasale at activenetwerx.com
Sun Oct 23 15:44:53 EDT 2016


> Interesting. Generally, I allocate cursors exactly at the same time as I open transactions;
> not sure if this works with the mysql connector, but with psycopg2 (PostgreSQL), my code looks like this:
> 
> with conn, conn.cursor() as cur:
>     cur.execute(...)
>     ... = cur.fetchall()
>
> The 'with' block guarantees that (a) the cursor will be closed and all resources freed, and (b) the
> transaction will be committed or rolled back (on exception, roll back, otherwise commit), at the unindent.
> It's a nice, clean way to operate. Never had problems with it.

Ditto, however the official Oracle python module lacks context managers.

Regardless, using try/finally and creating and closing cursors for both the query and the update
still did not help. The connection must be reset in order for the query to see new results.
That sounds ridiculous, certainly I overlooking something in a connection parameter possibly?

Thanks,
jlc



More information about the Python-list mailing list