Hi Michael,

Does the behavior of result.lastrowid change after SQLAlchemy version
5.5?  It seems that in older versions lastrowid is the first id
inserted and in later versions lastrowid is the last id inserted.

RHH

On Fri, Apr 10, 2009 at 11:57 AM, Michael Bayer<mike...@zzzcomputing.com> wrote:
>
>
>
> call result.lastrowid.  you'll get whatever the DBAPI deems worthy of
> sending.
>
>
> Andrija Frincic aka BobRock wrote:
>>
>> Hi all
>> I use insert statement as text to insert record into MySQL DB. I chose
>> this method because I use INSERT in combination with SELECT, so there
>> is no way to use SQL Expression language. My problem is that there is
>> no inserted ids available after inserting data using raw SQL
>> statement. When I call last_inserted_ids on ResultProxy returned by
>> session.execute I get following exception:
>> AttributeError: 'MySQLExecutionContext' object has no attribute
>> '_last_inserted_ids'.
>> Here is a sample code:
>> ins = """insert into visitor(queueid, firstname, uid, added,
>> description, queue_pos
>> select :queueid, :firstname, :uid, :added, :description, max(queue_pos)
>> +1 FROM visitor WHERE DATE(added)=DATE(:added) AND queueid=:queueid"""
>> res = meta.Session.execute(ins, self.form_result);
>> meta.Session.commit()
>> ids = res.last_inserted_ids();
>>
>> I use SQL alchemy 0.5.2 with Pylons and with MySQLDb 1.2.3b1 and
>> Python 2.6. Could someone point me how to get id of inserted  record.
>>
>> Best regards
>> Andrija
>>
>> >
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to