Re: Handling transactions in Python DBI module

2016-02-11 Thread dieter
Chris Angelico writes: > On Thu, Feb 11, 2016 at 6:59 PM, dieter wrote: >> In my context (web applications), I strongly discourage this use - at least >> when "conn" does not handle subtransactions properly. >> >> In a web application, the main transaction should in general be controlled >> at t

Re: Handling transactions in Python DBI module

2016-02-11 Thread Israel Brewster
On Feb 10, 2016, at 8:06 PM, Frank Millman wrote: > > "Israel Brewster" wrote in message > news:92d3c964-0323-46ee-b770-b89e7e7e6...@ravnalaska.net... > >> I am working on implementing a Python DB API module, and am hoping I can get >> some help with figuring out the workflow of handling tran

Re: Handling transactions in Python DBI module

2016-02-11 Thread Israel Brewster
On Feb 10, 2016, at 8:14 PM, Chris Angelico wrote: > > On Thu, Feb 11, 2016 at 4:06 PM, Frank Millman wrote: >> A connection has 2 possible states - 'in transaction', or 'not in >> transaction'. When you create the connection it starts off as 'not'. >> >> When you call cur.execute(), it checks

Re: Handling transactions in Python DBI module

2016-02-11 Thread Chris Angelico
On Thu, Feb 11, 2016 at 6:59 PM, dieter wrote: > In my context (web applications), I strongly discourage this use - at least > when "conn" does not handle subtransactions properly. > > In a web application, the main transaction should in general be controlled > at the request level: a request shou

Re: Handling transactions in Python DBI module

2016-02-11 Thread dieter
Israel Brewster writes: > I am working on implementing a Python DB API module, and am hoping I can get > some help with figuring out the workflow of handling transactions. In my > experience (primarily with psycopg2) the workflow goes like this: > > - When you open a connection (or is it when y

Re: Handling transactions in Python DBI module

2016-02-11 Thread dieter
Chris Angelico writes: > ... > When I advise my students on basic databasing concepts, I recommend > this structure: > > conn = psycopg2.connect(...) > > with conn, conn.cursor() as cur: > cur.execute(...) > > The transaction block should always start at the 'with' block and end > when it exit

Re: Handling transactions in Python DBI module

2016-02-10 Thread Chris Angelico
On Thu, Feb 11, 2016 at 4:28 PM, Frank Millman wrote: > "Chris Angelico" wrote in message > news:captjjmphjvtckub6qr-vp_1epewxbgqxmfkepmohqp3papg...@mail.gmail.com... >> >> >> When I advise my students on basic databasing concepts, I recommend >> this structure: >> >> conn = psycopg2.connect(...)

Re: Handling transactions in Python DBI module

2016-02-10 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmphjvtckub6qr-vp_1epewxbgqxmfkepmohqp3papg...@mail.gmail.com... When I advise my students on basic databasing concepts, I recommend this structure: conn = psycopg2.connect(...) with conn, conn.cursor() as cur: cur.execute(...) Does this auto

Re: Handling transactions in Python DBI module

2016-02-10 Thread Chris Angelico
On Thu, Feb 11, 2016 at 4:06 PM, Frank Millman wrote: > A connection has 2 possible states - 'in transaction', or 'not in > transaction'. When you create the connection it starts off as 'not'. > > When you call cur.execute(), it checks to see what state it is in. If the > state is 'not', it silent

Re: Handling transactions in Python DBI module

2016-02-10 Thread Frank Millman
"Israel Brewster" wrote in message news:92d3c964-0323-46ee-b770-b89e7e7e6...@ravnalaska.net... I am working on implementing a Python DB API module, and am hoping I can get some help with figuring out the workflow of handling transactions. In my experience (primarily with psycopg2) the workfl

Handling transactions in Python DBI module

2016-02-10 Thread Israel Brewster
I am working on implementing a Python DB API module, and am hoping I can get some help with figuring out the workflow of handling transactions. In my experience (primarily with psycopg2) the workflow goes like this: - When you open a connection (or is it when you get a cursor? I *think* it is o