-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hello,

i was following this thread with interest, and found that
last_inserted_ids returns the oid of the inserted record.

can i portably retrieve a record by this oid?

alex

mc wrote:
> here is a working script, (need to change connection parameters , of
> course).
> When I run it the output is:
> [1L]
> [2L]
> 
> Excpected according to documentation:
> ['Jack']
> ['Jill']
> 
> ###
> 
> from sqlalchemy import *
> db=create_engine('mysql://user1:[EMAIL PROTECTED]/tests')
> 
> create_s = """
> CREATE TABLE `users` (
> `user_name` varchar(16)  NOT NULL ,
> `ID` int unsigned NOT NULL auto_increment,
> PRIMARY KEY  (`user_name`),
> UNIQUE (`ID`)
> ) ENGINE=InnoDB
> """
> 
> db.execute("DROP TABLE IF EXISTS `users`")
> db.execute(create_s)
> 
> md=BoundMetaData(db)
> t=Table('users', md, autoload = True)
> 
> r = t.insert().execute(user_name='Jack')
> print r.last_inserted_ids()
> 
> r = t.insert().execute(user_name='Jill')
> print r.last_inserted_ids()
> 
> ###
> 
> 
> On Jul 6, 4:24 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
>> On Jul 6, 2007, at 4:33 AM, mc wrote:
>>
>>
>>
>>> I am using 0.3.6  and reading the 0.3 doc.
>>> The problem is that actually I need it the way it works for me now,
>>> i.e. returning the auto_increment fields and not my primary key
>>> fields.
>>> Will upgrading sqlalchemy break this (undocumented) feature?
>> as I said, i dont think what you describe is possible - only columns
>> explicitly marked as "primary key" get placed into last_inserted_ids
>> ().  a column that is only auto_increment will not be placed in this
>> result.  please send a working test script which illustrates the
>> behavior you are seeing.
> 
> 
> > 
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBRpE0I9pwN1sq38njAQJxvwP+M9m1YErgTRp6oPCk79JdlkL8BbIjda5a
Nsy0aEyiq5/oOvqP0mClGCjVNWvMVCdAH0+Sy9O5hOHkWEBGEjVIQ3A78QqjqOjM
eVQ2e/Ngfmgr1TwqQPe9TIpxhp5U3cqEWWHULOvKiK2f0ZwhatPEBBjMy3cRmOjB
Yg2MrWg1ywY=
=RRu3
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
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