Permalink
Browse files

Added executerowcount to be used to return rowcount of the query

re: issue #333: database: should return rowcount on execute
  • Loading branch information...
1 parent 00bb10c commit 76255cc1d326232a89dac047fd381dc6a557f4f7 @bkendall committed Aug 18, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 tornado/database.py
View
@@ -132,6 +132,15 @@ def execute(self, query, *parameters):
finally:
cursor.close()
+ def executerowcount(self, query, *parameters):
+ """Executes the given query, returning the number of rows affected from the query."""
+ cursor = self._cursor()
+ try:
+ self._execute(cursor, query, parameters)
+ return cursor.rowcount
+ finally:
+ cursor.close()
+
def executemany(self, query, parameters):
"""Executes the given query against all the given param sequences.

0 comments on commit 76255cc

Please sign in to comment.