class BaseCursorResult(object):
Known subclasses: sqlalchemy.engine.cursor.CursorResult
Method | __init__ |
Undocumented |
Method | _init_metadata |
Undocumented |
Method | _soft_close |
Soft close this _engine.CursorResult . |
Method | last_inserted_params |
Return the collection of inserted parameters from this execution. |
Method | last_updated_params |
Return the collection of updated parameters from this execution. |
Method | lastrow_has_defaults |
Return lastrow_has_defaults() from the underlying .ExecutionContext . |
Method | postfetch_cols |
Return postfetch_cols() from the underlying .ExecutionContext . |
Method | prefetch_cols |
Return prefetch_cols() from the underlying .ExecutionContext . |
Method | supports_sane_multi_rowcount |
Return supports_sane_multi_rowcount from the dialect. |
Method | supports_sane_rowcount |
Return supports_sane_rowcount from the dialect. |
Class Variable | out_parameters |
Undocumented |
Instance Variable | _echo |
Undocumented |
Instance Variable | _metadata |
Undocumented |
Instance Variable | _row_logging_fn |
Undocumented |
Instance Variable | _soft_closed |
Undocumented |
Instance Variable | closed |
Undocumented |
Instance Variable | connection |
Undocumented |
Instance Variable | context |
Undocumented |
Instance Variable | cursor |
Undocumented |
Instance Variable | cursor_strategy |
Undocumented |
Instance Variable | dialect |
Undocumented |
Property | inserted_primary_key |
Return the primary key for the row just inserted. |
Property | inserted_primary_key_rows |
Return the value of _engine.CursorResult.inserted_primary_key as a row contained within a list; some dialects may support a multiple row form as well. |
Property | is_insert |
True if this _engine.CursorResult is the result of a executing an expression language compiled _expression.insert construct. |
Property | lastrowid |
Return the 'lastrowid' accessor on the DBAPI cursor. |
Property | returned_defaults |
Return the values of default columns that were fetched using the .ValuesBase.return_defaults feature. |
Property | returned_defaults_rows |
Return a list of rows each containing the values of default columns that were fetched using the .ValuesBase.return_defaults feature. |
Property | returns_rows |
True if this _engine.CursorResult returns zero or more rows. |
Property | rowcount |
Return the 'rowcount' for this result. |
sqlalchemy.engine.cursor.LegacyCursorResult
Soft close this _engine.CursorResult
.
This releases all DBAPI cursor resources, but leaves the CursorResult "open" from a semantic perspective, meaning the fetchXXX() methods will continue to return empty results.
This method is called automatically when:
This method is not public, but is documented in order to clarify the "autoclose" process used.
See Also
_engine.CursorResult.close
Return the collection of inserted parameters from this execution.
Raises ~sqlalchemy.exc.InvalidRequestError
if the executed
statement is not a compiled expression construct
or is not an insert() construct.
Return the collection of updated parameters from this execution.
Raises ~sqlalchemy.exc.InvalidRequestError
if the executed
statement is not a compiled expression construct
or is not an update() construct.
Return lastrow_has_defaults() from the underlying
.ExecutionContext
.
See .ExecutionContext
for details.
Return postfetch_cols() from the underlying
.ExecutionContext
.
See .ExecutionContext
for details.
Raises ~sqlalchemy.exc.InvalidRequestError
if the executed
statement is not a compiled expression construct
or is not an insert() or update() construct.
Return prefetch_cols() from the underlying
.ExecutionContext
.
See .ExecutionContext
for details.
Raises ~sqlalchemy.exc.InvalidRequestError
if the executed
statement is not a compiled expression construct
or is not an insert() or update() construct.
Return supports_sane_multi_rowcount from the dialect.
See _engine.CursorResult.rowcount
for background.
Return supports_sane_rowcount from the dialect.
See _engine.CursorResult.rowcount
for background.
Return the primary key for the row just inserted.
The return value is a _result.Row
object representing
a named tuple of primary key values in the order in which the
primary key columns are configured in the source
_schema.Table
.
_engine.CursorResult.inserted_primary_key
value is now a named tuple via the _result.Row
class,
rather than a plain tuple.This accessor only applies to single row _expression.insert
constructs which did not explicitly specify
_expression.Insert.returning
. Support for multirow inserts,
while not yet available for most backends, would be accessed using
the _engine.CursorResult.inserted_primary_key_rows
accessor.
Note that primary key columns which specify a server_default clause, or
otherwise do not qualify as "autoincrement" columns (see the notes at
_schema.Column
), and were generated using the database-side
default, will appear in this list as None unless the backend
supports "returning" and the insert statement executed with the
"implicit returning" enabled.
Raises ~sqlalchemy.exc.InvalidRequestError
if the executed
statement is not a compiled expression construct
or is not an insert() construct.
Return the value of _engine.CursorResult.inserted_primary_key
as a row contained within a list; some dialects may support a
multiple row form as well.
Note
As indicated below, in current SQLAlchemy versions this
accessor is only useful beyond what's already supplied by
_engine.CursorResult.inserted_primary_key
when using the
:ref:`postgresql_psycopg2` dialect. Future versions hope to
generalize this feature to more dialects.
This accessor is added to support dialects that offer the feature that is currently implemented by the :ref:`psycopg2_executemany_mode` feature, currently only the psycopg2 dialect, which provides for many rows to be INSERTed at once while still retaining the behavior of being able to return server-generated primary key values.
_engine.Connection.execute
, this accessor
will then provide a list of rows, where each row contains the primary
key value for each row that was INSERTed._engine.CursorResult.inserted_primary_key
within a
single-element list. When an INSERT statement is executed in
conjunction with a list of rows to be INSERTed, the list will contain
one row per row inserted in the statement, however it will contain
None for any server-generated values.Future releases of SQLAlchemy will further generalize the "fast execution helper" feature of psycopg2 to suit other dialects, thus allowing this accessor to be of more general use.
See Also
_engine.CursorResult.inserted_primary_key
True if this _engine.CursorResult
is the result
of a executing an expression language compiled
_expression.insert
construct.
When True, this implies that the
inserted_primary_key
attribute is accessible,
assuming the statement did not include
a user defined "returning" construct.
Return the 'lastrowid' accessor on the DBAPI cursor.
This is a DBAPI specific method and is only functional for those backends which support it, for statements where it is appropriate. It's behavior is not consistent across backends.
Usage of this method is normally unnecessary when
using insert() expression constructs; the
~CursorResult.inserted_primary_key
attribute provides a
tuple of primary key values for a newly inserted row,
regardless of database backend.
Return the values of default columns that were fetched using
the .ValuesBase.return_defaults
feature.
The value is an instance of .Row
, or None
if .ValuesBase.return_defaults
was not used or if the
backend does not support RETURNING.
See Also
.ValuesBase.return_defaults
Return a list of rows each containing the values of default
columns that were fetched using
the .ValuesBase.return_defaults
feature.
The return value is a list of .Row
objects.
True if this _engine.CursorResult
returns zero or more rows.
I.e. if it is legal to call the methods
_engine.CursorResult.fetchone
,
_engine.CursorResult.fetchmany
_engine.CursorResult.fetchall
.
Overall, the value of _engine.CursorResult.returns_rows
should
always be synonymous with whether or not the DBAPI cursor had a
.description attribute, indicating the presence of result columns,
noting that a cursor that returns zero rows still has a
.description if a row-returning statement was emitted.
This attribute should be True for all results that are against SELECT statements, as well as for DML statements INSERT/UPDATE/DELETE that use RETURNING. For INSERT/UPDATE/DELETE statements that were not using RETURNING, the value will usually be False, however there are some dialect-specific exceptions to this, such as when using the MSSQL / pyodbc dialect a SELECT is emitted inline in order to retrieve an inserted primary key value.
Return the 'rowcount' for this result.
The 'rowcount' reports the number of rows matched by the WHERE criterion of an UPDATE or DELETE statement.
Note
Notes regarding _engine.CursorResult.rowcount
:
_engine.CursorResult.rowcount
is only useful in conjunction
with an UPDATE or DELETE statement. Contrary to what the Python
DBAPI says, it does not return the
number of rows available from the results of a SELECT statement
as DBAPIs cannot support this functionality when rows are
unbuffered._engine.CursorResult.rowcount
may not be fully implemented by
all dialects. In particular, most DBAPIs do not support an
aggregate rowcount result from an executemany call.
The _engine.CursorResult.supports_sane_rowcount
and
_engine.CursorResult.supports_sane_multi_rowcount
methods
will report from the dialect if each usage is known to be
supported.See Also
:ref:`tutorial_update_delete_rowcount` - in the :ref:`unified_tutorial`