From: | Gerhard Häring <haering_postgresql(at)gmx(dot)de> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: Python DB-API problem with PostgresSQL pgdb. |
Date: | 2003-01-28 09:00:06 |
Message-ID: | 20030128090005.GA1320@HAERING2 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Carwyn Edwards <cedward1(at)inf(dot)ed(dot)ac(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Jeroen T. Vermeulen | 2003-01-29 13:13:39 | Re: Difficulty getting started with Postgres C++ interface |
Previous Message | David Wright | 2003-01-27 22:42:11 | Difficulty getting started with Postgres C++ interface |