[egenix-users] how to insert new row, update in-memory object with same row from database?

M.-A. Lemburg mal at lemburg.com
Mon Dec 30 19:09:58 CET 2002


Michael Rothwell wrote:
> M.-A. Lemburg wrote:
> 
>>
>> The DB-API lists a standard extension for this purpose:
>>
>> Cursor Attribute .lastrowid
> 
> 
> It doesn't look like mx.ODBC supports it -- "attribute error," and a 
> search through the .py files produces no matches for "lastrowid."

Right. That's because ODBC doesn't allow querying this information
(at least not to my knowledge).

>> That way you know the identity of the row *before* inserting
>> it -- usually much better if you plan to use contraints and
>> the like on the table.
>>
> Yeah, but that doesn't do me any good when working with a pre-existing 
> database schema.

In that case you'll have to figure out a set of columns using
.specialcolumns(). I still don't understand how you would
identify a newly inserted row like this, though. If the database
provides defaults and maybe uses a trigger to fill in an ID
column, then the knowledge of such a column wouldn't get you
any further. Maybe I'm missing something ?

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/




More information about the egenix-users mailing list