From: Billy G. Allie <Bill.Allie@mug.org>
To: Nagy Laszlo Zsolt , KLTE TTK pm1 <nagylzs@dragon.klte.hu>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: PyGreSQL and transactions
Date: Thu, 20 Jul 2000 18:07:19 -0400
Message-ID: <200007202207.SAA20408@bajor.mug.org> (raw)
In-Reply-To: <Pine.GSO.4.10.10007201213310.24509-100000@dragon>
"Nagy Laszlo Zsolt , KLTE TTK pm1" wrote:
>
> 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.)
>
I have a Python to PostgreSQL interface program that I am preparing to release.
It has the following features:
1. Support for cursors using 'DECLARE ... ' systax.
2. Support the following PostgreSQL typs as Python objects:
PG_BOOL, PG_INT2, PG_INT4, PG_INT8, PG_FLOAT4 PG_FLOAT8, PG_CHAR,
PG_VARCHAR, PG_TEXT, PG_BLOB (Large Objects), PG_NUMERIC
The PG_NUMERIC support include *, /, +, and - operators.
The PG_BLOB fully emulates a Python File Object except for truncate().
3. Support for PostgreSQL arrays. They are converted to/from Python lists on
input/output.
4. PostgreSQL notices are made available via the notices attribute of a
connection object. The
notices attribute is implemented as a list of notices such that
connection.notices.pop() will
return the first notice recieved from the back-end. Coalling pop() will
return the next
notice received, and so on.
5. Traps attempts to drop tables/indices, and unlinking large objects within
a transasction.
These actions are dangerous, since they can not be successfully rolled
back with the current
version of PostgreSQL. If the transactions were aborted or rolled back,
the database will be
left in a state where accessing the table, index, or large object that
was dropped will result
in an error because PostgreSQL can not access the file associated with
the table/index/LO.
I have been using the interface for about a week now without problems., but
have only been using it on UnixWare 7.0. If you are interested in using the
interface, I can send it to you and provide some assistance in porting it to
your environement (if needed).
> 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.
> >>>
Large Objects can only be opened and used in a transaction.
--
____ | Billy G. Allie | Domain....: Bill.Allie@mug.org
| /| | 7436 Hartwell | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
|/ |LLIE | (313) 582-1540 |
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: Bill.Allie@mug.org, nagylzs@dragon.klte.hu
Subject: Re: PyGreSQL and transactions
In-Reply-To: <200007202207.SAA20408@bajor.mug.org>
* 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