session imported from Meta ? If use Meta.Session.execute it's returns RowProxy, which has no lastrowid parameter.
On 16 сен, 02:59, Michael Bayer <mike...@zzzcomputing.com> wrote: > no its not a column on a row, its on the ResultProxy: > > result = session.execute('...') > > id = result.lastrowid > > http://www.sqlalchemy.org/docs/core/connections.html?highlight=result... > > On Sep 15, 2010, at 5:51 PM, phasma wrote: > > > > > Lastrowid return: "Could not locate column in row for column > > 'lastrowid'". I try to use transaction: > > > trans = meta.Session.begin() > > try: > > meta.Session.execute("INSERT statement") > > result = meta.Session.execute("SELECT LAST_INSERT_ID()") > > trans.commit() > > except: > > trans.rollback() > > raise > > > Now, I'm testing this, think it helps to stop loosing session between > > INSERT and SELECT. > > > On 15 ÓÅÎ, 21:45, Michael Bayer <mike...@zzzcomputing.com> wrote: > >> "SELECT LAST_INSERT_ID()" is ultimately where the value comes from - the > >> raw .lastrowid is present on the ResultProxy for those DBAPIs which > >> support it, so try using that. Perhaps you're getting "0" because the > >> transaction is going away, in which case .lastrowid should solve that > >> issue. > > >> On Sep 15, 2010, at 12:45 PM, phasma wrote: > > >>> I've got database with auto increment column called `id` and INSERT > >>> query, whom I need to execute without model declaration in project. > >>> meta.Session.execute() returns ResultProxy, but last_inserted_ids() > >>> doesn't work with execute() and "SELECT LAST_INSERT_ID()" statement > >>> sometimes return 0. Is there any other way to fetch last inserted id ? > > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "sqlalchemy" group. > >>> To post to this group, send email to sqlalch...@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> sqlalchemy+unsubscr...@googlegroups.com. > >>> For more options, visit this group > >>> athttp://groups.google.com/group/sqlalchemy?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to sqlalch...@googlegroups.com. > > To unsubscribe from this group, send email to > > sqlalchemy+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.