Received: from web118.yahoomail.com (web118.yahoomail.com [205.180.60.99]) by hub.org (8.10.1/8.10.1) with SMTP id e6LHSYh69627 for ; Fri, 21 Jul 2000 13:28:35 -0400 (EDT) Received: (qmail 11426 invoked by uid 60001); 21 Jul 2000 17:28:29 -0000 Message-ID: <20000721172829.11425.qmail@web118.yahoomail.com> Received: from [204.31.203.254] by web118.yahoomail.com; Fri, 21 Jul 2000 10:28:29 PDT Date: Fri, 21 Jul 2000 10:28:29 -0700 (PDT) From: Jason Earl Subject: Re: PyGreSQL and transactions To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200007/173 "Nagy Laszlo Zsolt , KLTE TTK pm1" writes: > Hi all. > > I'm writting a text-based server program with PyGreSQL. > My first problem follows: > > >>> import pg > >>> db = pg.DB('gandalf','localhost',5432,None,None,'gandalf','') > >>> db.query('BEGIN') > >>> db.query("INSERT INTO tbl(s) VALUES('value1')") > NOTICE: current transaction is aborted, queries ignored until end of transaction block > >>> db.query('commit') > >>> > > The notice was sent to stderr, it seems that I have no way to catch > it. There is getnotify(), but there is no getnotice(). I must catch > it, because my server must know if the operation was successful. (It > is in a multi-tier application's middle, and sends back a message > about the operation.) Using both the older 2.4 version of PyGreSQL and the newer 3.1 version that I am using you can catch these errors with a try/except block: db.query('BEGIN') try: db.query("INSERT INTO tbl(s) VALUES('value1')") except (pg.error,), detail: print "The transaction has been aborted\n %s" % (detail,) db.query('ABORT') #not necessary > Second problem: > > >>> lo = db.locreate(pg.INV_WRITE) > >>> lo > Closed large object, oid 18863 > >>> lo.open(pg.INV_WRITE) > Traceback (innermost last): > File "", line 1, in ? > IOError: can't open large object. > >>> > > I have compiled the PyGreSQL module without -DNO_LARGE. You need to encapsulate your large object access in a transaction try starting with a: db.query('BEGIN') and ending it with: db.query('COMMIT') > Thank in advance: > > Laszlo Nagy > nagylzs@delfin.klte.hu I hope this helps. Jason -- The single most useful thing about the Internet is that it facilitates using Linux. To use Linux, you need so much goddamn technical information that if you don't have a really good source of technical support, you're just screwed. -- Neal Stephenson __________________________________________________ Do You Yahoo!? Get Yahoo! Mail – Free email you can access from anywhere! http://mail.yahoo.com/