Number of row updated or deleted

3,399 views
Skip to first unread message

Joojle

unread,
Sep 28, 2009, 11:39:12 PM9/28/09
to sqlalchemy
Can I know How many rows affected on update or detete on
connect.execute()

Laurent Rahuel

unread,
Sep 29, 2009, 5:09:09 AM9/29/09
to sqlal...@googlegroups.com
Hi,

You should take a look at session.dirty (which contains rows to update)
and session.delete (which contains rows to delete)

Regards,

Laurent

Mike Conley

unread,
Sep 29, 2009, 8:13:33 AM9/29/09
to sqlal...@googlegroups.com
Use rowcount property of the ResultProxy returned from delete/update

result = conn.execute(tbl.delete())
count = result.rowcount

Note that the quality of the number will depend on the underlying database and Python dbapi.

Reply all
Reply to author
Forward
0 new messages