summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2005-09-03 20:53:28 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2005-09-03 20:53:28 +0000
commite97d30dbfe58202ba16688cfc00a36e440021254 (patch)
treea54afd6ad70d902fab8ef391ff74df7266f465d7 /lib/sqlalchemy/sql.py
parent99cb7b09378703a4158d302888bd41734130f2da (diff)
downloadsqlalchemy-e97d30dbfe58202ba16688cfc00a36e440021254.tar.gz
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r--lib/sqlalchemy/sql.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index f2617d2a2..b80436cde 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -175,9 +175,13 @@ class Compiled(ClauseVisitor):
those given in the **params dictionary"""
raise NotImplementedError()
- def execute(self, **params):
+ def execute(self, *multiparams, **params):
"""executes this compiled object using the underlying SQLEngine"""
- return self.engine.execute(str(self), self.get_params(**params), echo = getattr(self.statement, 'echo', False), compiled = self)
+ if len(multiparams):
+ params = [self.get_params(**m) for m in multiparams]
+ else:
+ params = self.get_params(**params)
+ return self.engine.execute(str(self), params, echo = getattr(self.statement, 'echo', False), compiled = self)
class ClauseElement(object):
"""base class for elements of a programmatically constructed SQL expression.
@@ -221,13 +225,17 @@ class ClauseElement(object):
table columns should be used in the statement."""
return engine.compile(self, bindparams = bindparams)
- def execute(self, **params):
+ def execute(self, *multiparams, **params):
"""compiles and executes this SQL expression using its underlying SQLEngine.
the given **params are used as bind parameters when compiling and executing the expression.
the DBAPI cursor object is returned."""
e = self.engine
- c = self.compile(e, bindparams = params)
- return c.execute()
+ if len(multiparams):
+ bindparams = multiparams[0]
+ else:
+ bindparams = params
+ c = self.compile(e, bindparams = bindparams)
+ return c.execute(*multiparams, **params)
def result(self, **params):
"""the same as execute(), except a RowProxy object is returned instead of a DBAPI cursor."""