Anthony Tuininga wrote at 2007-6-21 16:39 -0600:
> ...
>> Is your transaction-controlling implementation of
>> connection.__enter__/__exit__ already released, i.e. is it too late to
>> get you to change the API to this feature?
>
>I have not released this publicly yet, no. It would be a good idea t
Anthony Tuininga wrote:
> Hmm, I've thought about this a bit more. If you look at the module
> contextlib in the Python 2.5 standard library you can see that making
> connections and cursors context managers that simply close themselves
> is redundant. You can do this instead:
>
> with contextlib.
Hmm, I've thought about this a bit more. If you look at the module
contextlib in the Python 2.5 standard library you can see that making
connections and cursors context managers that simply close themselves
is redundant. You can do this instead:
with contextlib.closing(connection.cursor()) as curs
On Thu, 2007-06-21 at 16:39 -0600, Anthony Tuininga wrote:
> I have not released this publicly yet, no. It would be a good idea to
> have agreement on this rather than have conflicting implementations.
Indeed. I see two alternatives, modulo naming:
1) A connection method:
with conn.transaction()
On 6/21/07, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Thu, 2007-06-21 at 14:26 -0600, Anthony Tuininga wrote:
> > On 6/21/07, Carsten Haese <[EMAIL PROTECTED]> wrote:
> > > with api.connect(dbname) as conn:
> > >with conn.cursor() as cur:
> > > cur.execute(stmt)
> >
> > That's interes
On Thu, 2007-06-21 at 14:26 -0600, Anthony Tuininga wrote:
> On 6/21/07, Carsten Haese <[EMAIL PROTECTED]> wrote:
> > with api.connect(dbname) as conn:
> >with conn.cursor() as cur:
> > cur.execute(stmt)
>
> That's interesting but is it of much use? Connections and cursors
> close themse
On 6/21/07, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Thu, 2007-06-21 at 10:41 -0600, Anthony Tuininga wrote:
> > I have been recently playing with context managers and the new "with"
> > statement added in Python 2.5. I would like to suggest the addition of
> > the following methods to connec
I'm not sure if there is a need for context support at the moment.
Almost all databases automatically rollback transactions if they are
not committed before a connection is closed. In the pyodbc connection
finalizer, I automatically issue a rollback if a commit didn't occur.
Since CPython uses re
On Thu, 2007-06-21 at 10:41 -0600, Anthony Tuininga wrote:
> I have been recently playing with context managers and the new "with"
> statement added in Python 2.5. I would like to suggest the addition of
> the following methods to connections:
>
> def __enter__(self):
> return self
>
> def _
On 2007-06-21 18:41, Anthony Tuininga wrote:
> I have been recently playing with context managers and the new "with"
> statement added in Python 2.5. I would like to suggest the addition of
> the following methods to connections:
>
> def __enter__(self):
> return self
>
> def __exit__(self,
Anthony Tuininga wrote:
> I have been recently playing with context managers and the new "with"
> statement added in Python 2.5. I would like to suggest the addition of
> the following methods to connections:
>
> def __enter__(self):
> return self
>
> def __exit__(self, excType, excValue, ex
I have been recently playing with context managers and the new "with"
statement added in Python 2.5. I would like to suggest the addition of
the following methods to connections:
def __enter__(self):
return self
def __exit__(self, excType, excValue, excTraceback):
if excType is None and
12 matches
Mail list logo