From: Gerhard Häring <haering_postgresql@gmx.de>
To: pgsql-interfaces@postgresql.org
Subject: Re: Python DB-API problem with PostgresSQL pgdb.
Date: Tue, 28 Jan 2003 10:00:06 +0100
Message-ID: <20030128090005.GA1320@HAERING2> (raw)
Carwyn Edwards <cedward1@inf.ed.ac.uk> wrote:
> The Python DB-API (2.0) specifies that on creation a connection object
> is to start a transaction if the database supports them. The pgdb
> implementation of the DB-API does this:
>
> >>> Begin Listing 1
> class pgdbCnx:
>
> def __init__(self, cnx):
> self.__cnx = cnx
> self.__cache = pgdbTypeCache(cnx)
> try:
> src = self.__cnx.source()
> src.execute("BEGIN")
> except:
> raise OperationalError, "invalid connection."
>
> >>> End Listing 1
pyPgSQL (and psycopg, IIRC) solves this problem by having a .autocommit
connection level setting. Just do con.autocommit = 1 before issuing any
statements that PostgreSQL cannot execute within a transaction.
I'd suggest you simply switch to one of these Python DB-API modules. Apart from
the .connect and import call you very likely won't have to change *anything* in
your code.
Btw. if anybody wants to patch PyGreSQL accordingly, they're welcome to help
themselves with the pyPgSQL source, as it's under a MIT-like license as well.
Btw. IIRC there are a few other DB-API modules that implement .autocommit as
well. Maybe one day this will make it into the DB-API optional extensions.
-- Gerhard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: haering_postgresql@gmx.de
Subject: Re: Python DB-API problem with PostgresSQL pgdb.
In-Reply-To: <20030128090005.GA1320@HAERING2>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox