Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Feature Request: Using pyodbc as context managers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
GotGTKWantWx  
View profile   Translate to Translated (View Original)
 More options Jun 1 2010, 11:07 am
From: GotGTKWantWx <gerald.brit...@gmail.com>
Date: Tue, 1 Jun 2010 08:07:11 -0700 (PDT)
Local: Tues, Jun 1 2010 11:07 am
Subject: Feature Request: Using pyodbc as context managers
I would like to propose adding support to pyodbc to enable its use as
a context manager.  That is, I would like the following to work:

import pyodbc
with pyodbc.connect (dsn='mydb') as conn:
    with conn.cursor() as curs:
          with curs.execute('select * from mytable) as selected:
                for row in selected:
                     #do something useful

This will mean adding __enter__ and __exit__ methods to these
objects.  I propose that __enter__ just return the object and __exit__
do something like:

1. for pyodbc.connect -- automatically close the connection
2. for cursor objects -- automatically commit (unless autocommit=false
in connect) and close the cursor
3. for execute -- not sure yet (maybe not as useful)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
amandara...@gmail.com  
View profile  
 More options Sep 22 2012, 10:49 pm
From: amandara...@gmail.com
Date: Sat, 22 Sep 2012 19:49:08 -0700 (PDT)
Local: Sat, Sep 22 2012 10:49 pm
Subject: Re: Feature Request: Using pyodbc as context managers

I came across this post while checking to see if pyodbc was possible to use
with "with" statements. +1 on this feature :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Kleehammer  
View profile  
 More options Sep 26 2012, 5:54 pm
From: Michael Kleehammer <mkleeham...@gmail.com>
Date: Wed, 26 Sep 2012 14:54:43 -0700 (PDT)
Local: Wed, Sep 26 2012 5:54 pm
Subject: Re: Feature Request: Using pyodbc as context managers

This has been checked in, so if you are building from source you can try it
today.

I'll try to cut 3.0.7 with this ASAP.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »