fetch(resultSpec,
sqlTemplate,
*values,
**kwargs)
a method that executes sql and returns rows of tuples of PyDO
objects and scalar values, ordered according to a result set
specification.
resultSpec is a list that may contain:
* PyDO classes;
* 2-tuples of (PyDO class, alias string), which indicate that
the table represented by the PyDO class is to be referenced by
the given alias;
* strings, which represent arbitrary SQL expressions that may
occur in a SQL column-list specification.
sqlTemplate is a string that may contain interpolation variables
in the style of string.Template. In particular, two variables are
supplied to this template automatically:
$COLUMNS -- a list of columns computed from the supplied resultSpec;
$TABLES -- a list of tables similarly computed.
Additional interpolation variables may be passed in as keyword
arguments. Bind variables to the SQL may also be passed in,
through positional arguments; if there is only one positional
argument, and it is a dictionary, it will be used instead of a
list of values, under the assumption that either the 'named' or
'pyformat' paramstyle is being used.
For each element E in the resultSpec, the result row contains one
element F. If E is a PyDO class, F will either be an instance of
E, or, if all its corresponding columns were null for that row and
E has a uniqueness constraint (which in PyDO is implicitly a not
null constraint), None. If E is a string, F will be whatever the
cursor returned for that column.
-
|