On Thu, 2011-05-26 at 14:35 +0200, Cédric Krier wrote:
> > Also, the move to 2.6+ will make code a lot more better since in
> your DB
> > connections, you can use the with statement. That means getting rid
> of
> > the ugly try..finally codes.
> 
> Do you mean that PEP249 cursor can be used as context? 

I don't know about the cursor. I've only used the Connector object like
that:

with database.connect(credentials) as conn:
    cursor = conn.cursor()
    ...

There's no need to have a try...finally because the connection is
guaranteed to be closed regardless of what happens (afaik).

-- 
[email protected] mailing list

Reply via email to