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.


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