Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Re: issue #333: database: should return rowcount on execute #338

Closed
wants to merge 1 commit into from

2 participants

Bryan Kendall Ben Darnell
Bryan Kendall

Added a function to return the rowcount from the cursor, which returns the rows affected when executing an UPDATE or DELETE.

Bryan Kendall bkendall Added executerowcount to be used to return rowcount of the query
re: issue #333: database: should return rowcount on execute
76255cc
Ben Darnell
Owner

I've committed a version of this change that spells the new method name with an underscore.

Ben Darnell bdarnell closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 18, 2011
  1. Bryan Kendall

    Added executerowcount to be used to return rowcount of the query

    bkendall authored
    re: issue #333: database: should return rowcount on execute
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +9 −0 tornado/database.py
9 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.
Something went wrong with that request. Please try again.