DP-Api 2 and autoincrement

Boudewijn Rempt boud at rempt.xs4all.nl
Thu Sep 30 09:25:14 EDT 1999


I'm trying to build a sort of object framework for a database application,
using the db-api II specification.  It's a bit like:

                          db-api
                            |
               thin connection object (dbObj)
                            |
                SQL abstraction layer (dbSQL)
                            |
                  record object (dbRecord)
                            |
                    table object (dbTable)

I also have a set of objects that define the tables, records and
relations, like a repository, so in theory the sql layer could generate
all necessary sql for inserting, updating, selecting, deleting and
working with child tables and so on. 

Now, most databases have some sort of sequence generator or autoincrement
datatypes, especially for surrogate keys. When my SQL layer inserts a
record, one field is left blank, and the database fills the number in.
I'd like to have the SQL layer return that number, so it can be entered
in the dbRecord object. Is there a way to get that number back from the
database using db-api II? I'd really hate to build a sequence generator
myself, or to try and find the number using selects before or after
inserts.

-- 

Boudewijn Rempt  | http://ww




More information about the Python-list mailing list