Mike Bayer  committed f0235df

DB connection errors wrapped in DBAPIErrors

  • Participants
  • Parent commits 976ca95
  • Branches default

Comments (0)

Files changed (3)

 - fixed up Boolean datatype
 - added count()/count_by() to list of methods proxied by assignmapper;
 this also adds them to activemapper
+- connection exceptions wrapped in DBAPIError
 - fixed endless loop bug in select_by(), if the traversal hit

File lib/sqlalchemy/engine/

             dbapi = dialect.dbapi()
             if dbapi is None:
                 raise exceptions.InvalidRequestError("Cant get DBAPI module for dialect '%s'" % dialect)
-            self._pool = poolclass(lambda: dbapi.connect(*cargs, **cparams), **kwargs)
+            def connect():
+                try:
+                    return dbapi.connect(*cargs, **cparams)
+                except Exception, e:
+                    raise exceptions.DBAPIError("Connection failed", e)
+            self._pool = poolclass(connect, **kwargs)
             if isinstance(pool, sqlalchemy.pool.DBProxy):
                 self._pool = pool.get_pool(*cargs, **cparams)

File lib/sqlalchemy/

 class DBAPIError(SQLAlchemyError):
     """something weird happened with a particular DBAPI version"""
-    pass
+    def __init__(self, message, orig):
+        SQLAlchemyError.__init__(self, "(%s) (%s) %s"% (message, orig.__class__.__name__, str(orig)))
+        self.orig = orig