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 [email protected]
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