On Dec 9, 2008, at 9:30 AM, Dusty Phillips wrote:

> After perusing the sqlalchemy sources, I realized that when
> session.commit() is called, it is indeed inserting the data into the
> database, but it is not updating the _rowid primary key on the User
> object that was created. The user object looks in the database for
> something with an id of 'None', which doesn't exist, causing it to
> think its deleted.

one of the key responsibilities of the dialect is to establish the  
methodology, if any, of creating new primary key identifiers.   Every  
database has a completely different way of going about this.   General  
methods include:

        1. integer primary key columns generate IDs automatically; the result  
is placed in cursor.lastrowid
        2. same as 1, but special DDL must be applied to the column first  
(i.e. MySQL's AUTOINCREMENT)
        3. integer pks generate using sequences, but don't interact with  
cursor.lastrowid so are explicitly pre-executed (postgres, oracle)
        4. other magic "select last_inserted_ids" type of SQL must be emitted  
(MSSQL)
        5. any of the above, but the DB supports INSERT...RETURNING and we  
can get the new ids back in one step

SQLA currently has examples of 1-4, with the style of #5 on deck.    
You need to identify which if any of these models Openbase uses and  
emulate it.

> Also, does anyone know of a tutorial or guideline for writing Alchemy
> dialects? Trying to get it from the source code of the existing
> databases is, while enlightening, taking a lot of time to grok.

the Dialect and ExecutionContext classes are documented fully (though  
there may be out of date docstrings).  The SQlite dialect is probably  
the simplest but a perusal around a couple of them would grant some  
perspective.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to