Re: PyGreSQL and transactions
От | Jason Earl |
---|---|
Тема | Re: PyGreSQL and transactions |
Дата | |
Msg-id | 20000721172829.11425.qmail@web118.yahoomail.com обсуждение исходный текст |
Ответ на | PyGreSQL and transactions ("Nagy Laszlo Zsolt , KLTE TTK pm1" <nagylzs@dragon.klte.hu>) |
Список | pgsql-interfaces |
"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/
В списке pgsql-interfaces по дате отправления: