MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/engine/cursor.py:372–541  ·  view source on GitHub ↗
(
        self,
        parent: CursorResult[Unpack[TupleAny]],
        cursor_description: _DBAPICursorDescription,
        *,
        driver_column_names: bool = False,
        num_sentinel_cols: int = 0,
    )

Source from the content-addressed store, hash-verified

370 )
371
372 def __init__(
373 self,
374 parent: CursorResult[Unpack[TupleAny]],
375 cursor_description: _DBAPICursorDescription,
376 *,
377 driver_column_names: bool = False,
378 num_sentinel_cols: int = 0,
379 ):
380 context = parent.context
381 if num_sentinel_cols > 0:
382 # this is slightly faster than letting tuplegetter use the indexes
383 self._tuplefilter = tuplefilter = operator.itemgetter(
384 slice(-num_sentinel_cols)
385 )
386 cursor_description = tuplefilter(cursor_description)
387 else:
388 self._tuplefilter = tuplefilter = None
389 self._translated_indexes = None
390 self._safe_for_cache = self._unpickled = False
391
392 if context.result_column_struct:
393 (
394 result_columns,
395 cols_are_ordered,
396 textual_ordered,
397 ad_hoc_textual,
398 loose_column_name_matching,
399 ) = context.result_column_struct
400 if tuplefilter is not None:
401 result_columns = tuplefilter(result_columns)
402 num_ctx_cols = len(result_columns)
403 else:
404 result_columns = cols_are_ordered = ( # type: ignore
405 num_ctx_cols
406 ) = ad_hoc_textual = loose_column_name_matching = (
407 textual_ordered
408 ) = False
409
410 # merge cursor.description with the column info
411 # present in the compiled structure, if any
412 raw = self._merge_cursor_description(
413 context,
414 cursor_description,
415 result_columns,
416 num_ctx_cols,
417 cols_are_ordered,
418 textual_ordered,
419 ad_hoc_textual,
420 loose_column_name_matching,
421 driver_column_names,
422 )
423
424 # processors in key order which are used when building up
425 # a row
426 self._processors = [
427 metadata_entry[MD_PROCESSOR] for metadata_entry in raw
428 ]
429 if num_sentinel_cols > 0:

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected