Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-28 Thread Steve Holden
Stuart Bishop wrote: [...] > If you are using a modern PostgreSQL (8.1 for sure, maybe 8.0), this is > better spelt: > > cur.execute("SELECT currval(pg_get_serial_sequence(%s, %s))" % ( > tableid, columnid)) > > (Assuming of course your table name and column name don't contain odd > character

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-27 Thread Stuart Bishop
Frank Millman wrote: > I used to use 'select lastval()', but I hit a problem. If I insert a > row into table A, I want the id of the row inserted. If it is a complex > insert, which triggers inserts into various other tables, some of which > may also be auto-incrementing, lastval() returns the id

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-16 Thread [EMAIL PROTECTED]
Frank Millman wrote: > Did you read my extract from the PostgreSQL docs - > > "Notice that because this is returning a session-local value, it gives > a predictable answer whether or not other sessions have executed > nextval since the current session did." > I totally missed it, my bad. Thanks!

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-16 Thread Frank Millman
[EMAIL PROTECTED] wrote: > Frank Millman wrote: > > Dale Strickland-Clark wrote: > > > Now that OIDs have been deprecated in PostgreSQL, how do you find the key > > > of > > > a newly inserted record? > > > > > > > > I used to use 'select lastval()', but I hit a problem. If I insert a > > row int

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-16 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Frank Millman wrote: > >>Dale Strickland-Clark wrote: >> >>>Now that OIDs have been deprecated in PostgreSQL, how do you find the key of >>>a newly inserted record? >>> > > >>I used to use 'select lastval()', but I hit a problem. If I insert a >>row into table A, I wan

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-16 Thread [EMAIL PROTECTED]
Frank Millman wrote: > Dale Strickland-Clark wrote: > > Now that OIDs have been deprecated in PostgreSQL, how do you find the key of > > a newly inserted record? > > > > I used to use 'select lastval()', but I hit a problem. If I insert a > row into table A, I want the id of the row inserted. If i

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-16 Thread Jim
Frank Millman wrote: > I therefore use the following - > cur.execute("select currval('%s_%s_Seq')" % (tableid, columnid) I use this also (although isn't it right that sometimes the name of the sequence is not so straightforward? for instance, isn't there a limit on the number of chars?). Can a

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-15 Thread Frank Millman
Dale Strickland-Clark wrote: > Now that OIDs have been deprecated in PostgreSQL, how do you find the key of > a newly inserted record? > > I've tried three Python client libraries, including psycopg2, and where they > support cursor attribute 'lastrowid' (Python DB API 2.0), it is always > zero. >

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-15 Thread Dale Strickland-Clark
Tim N. van der Leeuw wrote: > > Hi, > > select lastval(); > Thanks, that was useful. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-15 Thread Dale Strickland-Clark
Hi Harald Thanks for that, somewhat comprehensive, answer. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-15 Thread GHUM
Dale, > Now that OIDs have been deprecated in PostgreSQL, how do you find the key of > a newly inserted record? using OIDs as primary key was no good idea for some PostgreSQL versions allready ... i.e. they really make dump & restore much more challenging. So usually us have something along: CR

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-15 Thread Tim N. van der Leeuw
Dale Strickland-Clark wrote: > Now that OIDs have been deprecated in PostgreSQL, how do you find the key of > a newly inserted record? > > I've tried three Python client libraries, including psycopg2, and where they > support cursor attribute 'lastrowid' (Python DB API 2.0), it is always > zero. >