From: Jason Earl <jdearl@yahoo.com>
To: pgsql-interfaces@postgresql.org
Subject: Re: PyGreSQL and transactions
Date: Fri, 21 Jul 2000 10:28:29 -0700 (PDT)
Message-ID: <20000721172829.11425.qmail@web118.yahoomail.com> (raw)
"Nagy Laszlo Zsolt , KLTE TTK pm1"
<nagylzs@dragon.klte.hu> 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 "<stdin>", 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/
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: jdearl@yahoo.com
Subject: Re: PyGreSQL and transactions
In-Reply-To: <20000721172829.11425.qmail@web118.yahoomail.com>
* 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