summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-02-25 18:32:11 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-02-25 18:32:11 +0000
commit47418e0f87cb432e0d813c7c30e43822fa479e9e (patch)
tree8518b7a0a7c97679e34c280b06f3bbd26ae35baa /lib/sqlalchemy/engine
parent98d54ac067b4b9ddd6adb73468ea3f2d9d9b87ee (diff)
downloadsqlalchemy-47418e0f87cb432e0d813c7c30e43822fa479e9e.tar.gz
- added exception wrapping/reconnect support to result set
fetching. Reconnect works for those databases that raise a catchable data error during results (i.e. doesn't work on MySQL) [ticket:978]
Diffstat (limited to 'lib/sqlalchemy/engine')
-rw-r--r--lib/sqlalchemy/engine/base.py45
1 files changed, 31 insertions, 14 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 28951f900..bb52070fc 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -1616,30 +1616,47 @@ class ResultProxy(object):
def fetchall(self):
"""Fetch all rows, just like DB-API ``cursor.fetchall()``."""
- l = [self._process_row(self, row) for row in self._fetchall_impl()]
- self.close()
- return l
+ try:
+ l = [self._process_row(self, row) for row in self._fetchall_impl()]
+ self.close()
+ return l
+ except Exception, e:
+ self.connection._handle_dbapi_exception(e, None, None, self.cursor)
+ raise
def fetchmany(self, size=None):
"""Fetch many rows, just like DB-API ``cursor.fetchmany(size=cursor.arraysize)``."""
- l = [self._process_row(self, row) for row in self._fetchmany_impl(size)]
- if len(l) == 0:
- self.close()
- return l
+ try:
+ l = [self._process_row(self, row) for row in self._fetchmany_impl(size)]
+ if len(l) == 0:
+ self.close()
+ return l
+ except Exception, e:
+ self.connection._handle_dbapi_exception(e, None, None, self.cursor)
+ raise
def fetchone(self):
"""Fetch one row, just like DB-API ``cursor.fetchone()``."""
- row = self._fetchone_impl()
- if row is not None:
- return self._process_row(self, row)
- else:
- self.close()
- return None
+ try:
+ row = self._fetchone_impl()
+ if row is not None:
+ return self._process_row(self, row)
+ else:
+ self.close()
+ return None
+ except Exception, e:
+ self.connection._handle_dbapi_exception(e, None, None, self.cursor)
+ raise
def scalar(self):
"""Fetch the first column of the first row, and close the result set."""
- row = self._fetchone_impl()
+ try:
+ row = self._fetchone_impl()
+ except Exception, e:
+ self.connection._handle_dbapi_exception(e, None, None, self.cursor)
+ raise
+
try:
if row is not None:
return self._process_row(self, row)[0]