I'm trying to use SQLAlchemy's executemany syntax in PostgreSQL and get the last_inserted_ids(). What is the recommended way to get these last_inserted_ids()?
I know that I can access the id attribute for each model instance but there are hundreds of inserted rows and I would rather retrieve them all at once. Thanks, RHH >> names = ['ted', 'steve', 'mike'] >> result = meta.Session.execute(model.names_table.insert(), [{'name': x} for x >> in names]) >> result.last_inserted_ids() Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/WebError-0.10.1-py2.5.egg/weberror/evalcontext.py", line 35, in exec_expr exec code in self.namespace, self.globs File "<web>", line 1, in <module> File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/engine/base.py", line 1560, in last_inserted_ids return self.context.last_inserted_ids() File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/engine/default.py", line 284, in last_inserted_ids return self._last_inserted_ids AttributeError: 'PGExecutionContext' object has no attribute '_last_inserted_ids' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---