Re: EOF error

Adrian Klaver <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Wednesday 27 February 2008 7:58 pm, johnf wrote:
> On Wednesday 27 February 2008 06:09:31 pm Chris Cogdon wrote:
> > On Feb 27, 2008, at 17:47 , johnf wrote:
> > > On Wednesday 27 February 2008 05:23:59 pm you wrote:
> > >> On Feb 27, 2008, at 15:37 , johnf wrote:
> > >>> I got similar results.  I also get an entry into the log
> > >>> "Abort"  when I use connection.close().  But I don't get anything
> > >>> when I use
> > >>> del connection.
> > >>
> > >> You have a transaction in progress at the time ? Ie, perhaps you did
> > >> some select statements inside read_serializable mode ?
> > >
> > > I doubt that.  I just open the connection and then make a select
> > > and close.
> >
> > That would be a transaction ;) It happens under the hood in most
> > (all?) python-postgresql connectors. Upon the first statement
> > executed, the connector will open up a transaction, even if it's a
> > simple select statement.
> >
> > So, I just repeated your experiment, with FULL debugging on, and I
> > get this:
> >
> > 2008-02-27 18:10:46 PST (25214)> LOG:  statement: ABORT
> >
> > and if I do a "rollback" or a "commit" before I try and close, then I
> > DONT get the ABORT.
> >
> > So, yeah, you're inside a transaction,even after a simple select.
>
> OK so what is a guy suppose to do?  It seems like a no win situation.

When in doubt read the docs (something I have a problem with ):)

Setting transaction isolation levels

psycopg2 connection objects hold informations about the PostgreSQL transaction 
isolation level. The current transaction level can be read from 
the .isolation_level attribute. The default isolation level is READ 
COMMITTED. A different isolation level con be set through 
the .set_isolation_level() method. The level can be set to one of the 
following constants, defined in psycopg2.extensions:

ISOLATION_LEVEL_AUTOCOMMIT
    No transaction is started when command are issued and 
no .commit()/.rollback() is required. Some PostgreSQL command such as CREATE 
DATABASE can't run into a transaction: to run such command 
use .set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT).
ISOLATION_LEVEL_READ_COMMITTED
    This is the default value. A new transaction is started at the 
first .execute() command on a cursor and at each new .execute() after 
a .commit() or a .rollback(). The transaction runs in the PostgreSQL READ 
COMMITTED isolation level.
ISOLATION_LEVEL_SERIALIZABLE
    Transactions are run at a SERIALIZABLE isolation level.


So you may or may not be in a transaction.
-- 
Adrian Klaver
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.