Database Sessions and Transactions

DeepBlue DeepBlue at DeepBlue.org
Mon Oct 22 17:27:31 EDT 2001


This is in reply to Steve and Paul:
Actually what happened is that I worked on a cgi program in Delphi 5 and
immediately after that I started checking on Python to use it on a Sun
computer for a cgi program.  Believe it or not, on Friday afternoon, I mixed
up my terminology between the two languages while I was trying to understand
CGI and connecting to databases using Python.
Steve answered the first part on transactions.  Anyway, in Delphi 5,
StartTransaction is an attribute of a database connection.
Say you have a database component.
Database.StartTransaction 'packages' a transaction.  However, I can see now
that we do not need this.  The question is:  What are the advantages of
StartTransaction on a database connection?  I can see that in Python one
issues sql commands to a database and one can 'envelope' them in some form
of a transaction.  So instead of asking where is the transaction in Python,
I have turned to think about the use of StartTransaction in
Delphi.............. [continued below]

"Paul Boddie" <paul at boddie.net> wrote in message
news:23891c90.0110220232.1b0e9139 at posting.google.com...
> "DeepBlue" <DeepBlue at DeepBlue.org> wrote in message
news:<tt0os832km0dbb at corp.supernews.com>...
> > I am working on a CGI program in Python that connects to an Oracle
database.
> > I am wondering on how to implement a transaction that belongs to a
database
> > connection so that everything that belongs to the transaction can be
rolled
> > back.
>
> Assuming that there isn't anything that the CGI program talks to,
> between itself and the database system, which holds the connection
> object and keeps the connection open...
>
> > In other words, the scope of the rollback is NOT the database connection
BUT
> > the transaction that is defined from within the database connection.
>
> ...you appear to want to be able to open a connection by instantiating
> a connection object, explicitly define a transaction, do some work,
> suspend the transaction as you close the connection, and then upon a
> subsequent invocation of your CGI program, re-open the connection and
> resume the transaction.
>
Not quite.  As I said above, I as thinking more in Delphi terms where one
can use the StartTransaction attribute to 'package' a set of sql commands.
Now, I am not even sure anymore what is the need for this after Steve's
reply.
Anyway, the issues are clear in my mind now regarding transactions.


> > Also, I can find no reference in Python DB API 2 to Sessions.  How do we
> > manage different sessions/connections?
>
> There will definitely be people who know more about this than I do,
> but you should subscribe to the DB-SIG mailing list and post your
> question there - you can find the subscription page from
> http://www.python.org, of course.

Thanks, I will!
But to summarize:  when I posted my question I was thinking in Delphi 5
terms where one can use a Session component or when a session component is
created by default for every database connection.  A session manages an
individual database connection.  So when many users are using the same
program at the same time, every user is associated with a session to ensure
that multiple connections are kept independent from one another.  My concern
is what happens when many people log into a database through a Python cgi
program (I plan to use DCOracle2), how are these connections managed so that
we can ensure the integerity of independence of different transactions
performed.  In Python:  is the connection created with every logon denotes a
separate independent session to ensure integrity of data and transactions?
DeepBlue





More information about the Python-list mailing list