class documentation

class CursorResultMetaData(ResultMetaData): (source)

View In Hierarchy

Result metadata for DBAPI cursors.

Method __getstate__ Undocumented
Method __init__ Undocumented
Method __setstate__ Undocumented
Class Variable __slots__ Undocumented
Class Variable returns_rows Undocumented
Class Method _create_description_match_map when matching cursor.description to a set of names that are present in a Compiled object, as is the case with TextualSelect, get all the names we expect might match those in cursor.description.
Method _adapt_to_context When using a cached Compiled construct that has a _result_map, for a new statement that used the cached Compiled, we need to ensure the keymap has the Column objects from our new statement as keys. So here we rewrite keymap with new entries for the new columns as matched to those of the cached statement.
Method _colnames_from_description Extract column names and data types from a cursor.description.
Method _for_freeze Undocumented
Method _has_key Undocumented
Method _index_for_key Undocumented
Method _indexes_for_keys Undocumented
Method _key_fallback Undocumented
Method _make_new_metadata Undocumented
Method _merge_cols_by_name Undocumented
Method _merge_cols_by_none Undocumented
Method _merge_cursor_description Merge a cursor.description with compiled result column information.
Method _merge_textual_cols_by_position Undocumented
Method _metadata_for_keys Undocumented
Method _raise_for_ambiguous_column_name Undocumented
Method _reduce Undocumented
Method _remove_processors Undocumented
Method _splice_horizontally Undocumented
Instance Variable _keymap Undocumented
Instance Variable _keymap_by_result_column_idx Undocumented
Instance Variable _keys Undocumented
Instance Variable _processors Undocumented
Instance Variable _safe_for_cache Undocumented
Instance Variable _translated_indexes Undocumented
Instance Variable _tuplefilter Undocumented
Instance Variable _unpickled Undocumented

Inherited from ResultMetaData:

Property keys Undocumented
Method _getter Undocumented
Method _row_as_tuple_getter Undocumented
Class Variable _unique_filters Undocumented
def __getstate__(self): (source)

Undocumented

def __init__(self, parent: CursorResult[Any], cursor_description: _DBAPICursorDescription): (source)

Undocumented

def __setstate__(self, state): (source)

Undocumented

returns_rows: ClassVar[bool] = (source)

Undocumented

@classmethod
def _create_description_match_map(cls, result_columns: List[ResultColumnsEntry], loose_column_name_matching: bool = False) -> Dict[Union[str, object], Tuple[str, Tuple[Any, ...], TypeEngine[Any], int]]: (source)

when matching cursor.description to a set of names that are present in a Compiled object, as is the case with TextualSelect, get all the names we expect might match those in cursor.description.

def _adapt_to_context(self, context: ExecutionContext) -> ResultMetaData: (source)

When using a cached Compiled construct that has a _result_map, for a new statement that used the cached Compiled, we need to ensure the keymap has the Column objects from our new statement as keys. So here we rewrite keymap with new entries for the new columns as matched to those of the cached statement.

def _colnames_from_description(self, context, cursor_description): (source)

Extract column names and data types from a cursor.description. Applies unicode decoding, column translation, "normalization", and case sensitivity rules to the names based on the dialect.

def _has_key(self, key: Any) -> bool: (source)
def _index_for_key(self, key: Any, raiseerr: bool = True) -> Optional[int]: (source)
def _indexes_for_keys(self, keys): (source)
@overload
def _key_fallback(self, key: Any, err: Exception, raiseerr: Literal[True] = ...) -> NoReturn:
@overload
def _key_fallback(self, key: Any, err: Exception, raiseerr: Literal[False] = ...):
@overload
def _key_fallback(self, key: Any, err: Exception, raiseerr: bool = ...) -> Optional[NoReturn]:
(source)
def _make_new_metadata(self, *, unpickled: bool, processors: _ProcessorsType, keys: Sequence[str], keymap: _KeyMapType, tuplefilter: Optional[_TupleGetterType], translated_indexes: Optional[List[int]], safe_for_cache: bool, keymap_by_result_column_idx: Any) -> CursorResultMetaData: (source)

Undocumented

def _merge_cols_by_name(self, context, cursor_description, result_columns, loose_column_name_matching): (source)

Undocumented

def _merge_cols_by_none(self, context, cursor_description): (source)

Undocumented

def _merge_cursor_description(self, context, cursor_description, result_columns, num_ctx_cols, cols_are_ordered, textual_ordered, ad_hoc_textual, loose_column_name_matching): (source)

Merge a cursor.description with compiled result column information. There are at least four separate strategies used here, selected depending on the type of SQL construct used to start with. The most common case is that of the compiled SQL expression construct, which generated the column names present in the raw SQL string and which has the identical number of columns as were reported by cursor.description. In this case, we assume a 1-1 positional mapping between the entries in cursor.description and the compiled object. This is also the most performant case as we disregard extracting / decoding the column names present in cursor.description since we already have the desired name we generated in the compiled SQL construct. The next common case is that of the completely raw string SQL, such as passed to connection.execute(). In this case we have no compiled construct to work with, so we extract and decode the names from cursor.description and index those as the primary result row target keys. The remaining fairly common case is that of the textual SQL that includes at least partial column information; this is when we use a :class:`_expression.TextualSelect` construct. This construct may have unordered or ordered column information. In the ordered case, we merge the cursor.description and the compiled construct's information positionally, and warn if there are additional description names present, however we still decode the names in cursor.description as we don't have a guarantee that the names in the columns match on these. In the unordered case, we match names in cursor.description to that of the compiled construct based on name matching. In both of these cases, the cursor.description names and the column expression objects and names are indexed as result row target keys. The final case is much less common, where we have a compiled non-textual SQL expression construct, but the number of columns in cursor.description doesn't match what's in the compiled construct. We make the guess here that there might be textual column expressions in the compiled construct that themselves include a comma in them causing them to split. We do the same name-matching as with textual non-ordered columns. The name-matched system of merging is the same as that used by SQLAlchemy for all cases up through the 0.9 series. Positional matching for compiled SQL expressions was introduced in 1.0 as a major performance feature, and positional matching for textual :class:`_expression.TextualSelect` objects in 1.1. As name matching is no longer a common case, it was acceptable to factor it into smaller generator- oriented methods that are easier to understand, but incur slightly more performance overhead.

def _merge_textual_cols_by_position(self, context, cursor_description, result_columns): (source)

Undocumented

def _raise_for_ambiguous_column_name(self, rec): (source)
def _remove_processors(self) -> CursorResultMetaData: (source)

Undocumented

def _splice_horizontally(self, other: CursorResultMetaData) -> CursorResultMetaData: (source)

Undocumented

_keymap_by_result_column_idx = (source)

Undocumented

_safe_for_cache: bool = (source)

Undocumented

_unpickled: bool = (source)

Undocumented