summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r--lib/sqlalchemy/engine/base.py49
1 files changed, 27 insertions, 22 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 75d03b744..c0979ecac 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -6,18 +6,23 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from __future__ import with_statement
-"""Defines :class:`.Connection` and :class:`.Engine`.
+import contextlib
+import sys
-"""
+from .interfaces import Connectable
+from .interfaces import ExceptionContext
+from .util import _distill_params
+from .. import exc
+from .. import interfaces
+from .. import log
+from .. import util
+from ..sql import schema
+from ..sql import util as sql_util
-import sys
-from .. import exc, util, log, interfaces
-from ..sql import util as sql_util
-from ..sql import schema
-from .interfaces import Connectable, ExceptionContext
-from .util import _distill_params
-import contextlib
+"""Defines :class:`.Connection` and :class:`.Engine`.
+
+"""
class Connection(Connectable):
@@ -172,7 +177,7 @@ class Connection(Connectable):
def __enter__(self):
return self
- def __exit__(self, type, value, traceback):
+ def __exit__(self, type_, value, traceback):
self.close()
def execution_options(self, **opt):
@@ -321,7 +326,7 @@ class Connection(Connectable):
:ref:`schema_translating`
- """
+ """ # noqa
c = self._clone()
c._execution_options = c._execution_options.union(opt)
if self._has_events or self.engine._has_events:
@@ -892,15 +897,15 @@ class Connection(Connectable):
self.__can_reconnect = False
self.__transaction = None
- def scalar(self, object, *multiparams, **params):
+ def scalar(self, object_, *multiparams, **params):
"""Executes and returns the first column of the first row.
The underlying result/cursor is closed after execution.
"""
- return self.execute(object, *multiparams, **params).scalar()
+ return self.execute(object_, *multiparams, **params).scalar()
- def execute(self, object, *multiparams, **params):
+ def execute(self, object_, *multiparams, **params):
r"""Executes a SQL statement construct and returns a
:class:`.ResultProxy`.
@@ -959,12 +964,12 @@ class Connection(Connectable):
DBAPI-agnostic way, use the :func:`~.expression.text` construct.
"""
- if isinstance(object, util.string_types[0]):
- return self._execute_text(object, multiparams, params)
+ if isinstance(object_, util.string_types[0]):
+ return self._execute_text(object_, multiparams, params)
try:
- meth = object._execute_on_connection
+ meth = object_._execute_on_connection
except AttributeError:
- raise exc.ObjectNotExecutableError(object)
+ raise exc.ObjectNotExecutableError(object_)
else:
return meth(self, multiparams, params)
@@ -1698,8 +1703,8 @@ class Transaction(object):
def __enter__(self):
return self
- def __exit__(self, type, value, traceback):
- if type is None and self.is_active:
+ def __exit__(self, type_, value, traceback):
+ if type_ is None and self.is_active:
try:
self.commit()
except:
@@ -2005,8 +2010,8 @@ class Engine(Connectable, log.Identified):
def __enter__(self):
return self.conn
- def __exit__(self, type, value, traceback):
- if type is not None:
+ def __exit__(self, type_, value, traceback):
+ if type_ is not None:
self.transaction.rollback()
else:
self.transaction.commit()