MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/engine/cursor.py:363–510  ·  view source on GitHub ↗
(
        self,
        parent: CursorResult[Any],
        cursor_description: _DBAPICursorDescription,
    )

Source from the content-addressed store, hash-verified

361 )
362
363 def __init__(
364 self,
365 parent: CursorResult[Any],
366 cursor_description: _DBAPICursorDescription,
367 ):
368 context = parent.context
369 self._tuplefilter = None
370 self._translated_indexes = None
371 self._safe_for_cache = self._unpickled = False
372
373 if context.result_column_struct:
374 (
375 result_columns,
376 cols_are_ordered,
377 textual_ordered,
378 ad_hoc_textual,
379 loose_column_name_matching,
380 ) = context.result_column_struct
381 num_ctx_cols = len(result_columns)
382 else:
383 result_columns = cols_are_ordered = ( # type: ignore
384 num_ctx_cols
385 ) = ad_hoc_textual = loose_column_name_matching = (
386 textual_ordered
387 ) = False
388
389 # merge cursor.description with the column info
390 # present in the compiled structure, if any
391 raw = self._merge_cursor_description(
392 context,
393 cursor_description,
394 result_columns,
395 num_ctx_cols,
396 cols_are_ordered,
397 textual_ordered,
398 ad_hoc_textual,
399 loose_column_name_matching,
400 )
401
402 # processors in key order which are used when building up
403 # a row
404 self._processors = [
405 metadata_entry[MD_PROCESSOR] for metadata_entry in raw
406 ]
407
408 # this is used when using this ResultMetaData in a Core-only cache
409 # retrieval context. it's initialized on first cache retrieval
410 # when the _result_disable_adapt_to_context execution option
411 # (which the ORM generally sets) is not set.
412 self._keymap_by_result_column_idx = None
413
414 # for compiled SQL constructs, copy additional lookup keys into
415 # the key lookup map, such as Column objects, labels,
416 # column keys and other names
417 if num_ctx_cols:
418 # keymap by primary string...
419 by_key: Dict[_KeyType, _CursorKeyMapRecType] = {
420 metadata_entry[MD_LOOKUP_KEY]: metadata_entry

Callers

nothing calls this directly

Calls 5

_make_key_to_indexMethod · 0.80
setdefaultMethod · 0.45
addMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected