A few weeks ago, I tried to make a PostgreSQL backend for MiddleKit
using pyPgSQL. Unfortunately, it couldn't pursue this any further
because of a (IMO) bad design decision of MiddleKit:

It depends on there being something like MySQL's last_insert_id
available. (0) I strongly suggest removing this limitation, because it
simply cannot be done with PostgreSQL.

There are several possibilities to get the same result with PostgreSQL,
two good ones and one very ugly one:

1) You select nextval() from a sequence, then use the id in your INSERT
statement; this means you must know the name of the id column and the
name of the sequence in MiddleKit (possible, but suboptimal)

2) You make an INSERT statement on the table, which has an id primary
key "default nextval ..." on the sequence; then make another select
currval() on the sequence to get the last inserted id; this means you
must know the name of the id column and the name of the primary column
in Middlekit (possible, but suboptimal)

3) You make an INSERT statement on the table, don't use any id columns
at all, but abuse PostgreSQL's object ids. So next, you just ask
cursor.oidvalue in pyPgSQL to get the object id of the last inserted
row; which you could in turn use to get the value of the id column
(ugh!)

Which poison would yu choose? I'm in favour of option 0 :-)

Gerhard
-- 
This sig powered by Python!
Au�entemperatur in M�nchen: 17.9 �C      Wind: 1.8 m/s

_______________________________________________________________
Hundreds of nodes, one monster rendering program.
Now that's a super model! Visit http://clustering.foundries.sf.net/

_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to