Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 062DC476357 for ; Tue, 28 Jan 2003 04:01:56 -0500 (EST) Received: from opusnt3.opus-gmbh.net (mail.opus-gmbh.net [217.6.134.138]) by postgresql.org (Postfix) with ESMTP id 60E33475957 for ; Tue, 28 Jan 2003 04:01:45 -0500 (EST) Received: from haering2.opus-gmbh.net ([192.168.0.195]) by opusnt3.opus-gmbh.net with Microsoft SMTPSVC(5.0.2195.2966); Tue, 28 Jan 2003 10:00:06 +0100 Date: Tue, 28 Jan 2003 10:00:06 +0100 From: Gerhard =?iso-8859-1?Q?H=E4ring?= To: pgsql-interfaces@postgresql.org Subject: Re: Python DB-API problem with PostgresSQL pgdb. Message-ID: <20030128090005.GA1320@HAERING2> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.4i X-OriginalArrivalTime: 28 Jan 2003 09:00:06.0906 (UTC) FILETIME=[A757EDA0:01C2C6AB] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/106 X-Sequence-Number: 3606 Carwyn Edwards 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