Best practice for connections and cursors

Joseph L. Casale jcasale at activenetwerx.com
Fri Aug 2 09:10:50 EDT 2013


>Speaking to the OP:  personally, I don't like the approach of putting data access methods at the module level to >begin with.  I'd rather use a class.  Just because it makes sense to have a singleton connection now doesn't mean it >will always make sense as your application grows.
>In fact, the conflict you describe where one cursor is interfering with another cursor suggests that you may >already be at the point of needing multiple connections.  The operation that is creating a temp table and messing >things up should ideally be pulling an unused connection from a pool, so as to avoid potentially contaminating a >connection that may already be in use elsewhere in the code.

Appreciate the opinion, it would clean it up to go this route so I will. It turns out
the long delay was only a result of running the code through PyCharms debugger.

Thanks for the suggestion,
jlc



More information about the Python-list mailing list