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 > characters like = or ' or ., in which case you need to properly quote them). > > The reason it is better is that in odd cases the sequence name will not > always be %(tableid)s_%(columnid)s_seq, such as after you have renamed a > table. > Thank you! I've been looking for this for about six months - it helps to provide portability, and my current techniques relied on standard naming of the sequences.
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list