MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _exec_insertmany_context

Method _exec_insertmany_context

lib/sqlalchemy/engine/base.py:1968–2136  ·  view source on GitHub ↗

continue the _execute_context() method for an "insertmanyvalues" operation, which will invoke DBAPI cursor.execute() one or more times with individual log and event hook calls.

(
        self,
        dialect: Dialect,
        context: ExecutionContext,
    )

Source from the content-addressed store, hash-verified

1966 return result
1967
1968 def _exec_insertmany_context(
1969 self,
1970 dialect: Dialect,
1971 context: ExecutionContext,
1972 ) -> CursorResult[Unpack[TupleAny]]:
1973 """continue the _execute_context() method for an "insertmanyvalues"
1974 operation, which will invoke DBAPI
1975 cursor.execute() one or more times with individual log and
1976 event hook calls.
1977
1978 """
1979
1980 if dialect.bind_typing is BindTyping.SETINPUTSIZES:
1981 generic_setinputsizes = context._prepare_set_input_sizes()
1982 else:
1983 generic_setinputsizes = None
1984
1985 cursor, str_statement, parameters = (
1986 context.cursor,
1987 context.statement,
1988 context.parameters,
1989 )
1990
1991 effective_parameters = parameters
1992
1993 engine_events = self._has_events or self.engine._has_events
1994 if self.dialect._has_events:
1995 do_execute_dispatch: Iterable[Any] = (
1996 self.dialect.dispatch.do_execute
1997 )
1998 else:
1999 do_execute_dispatch = ()
2000
2001 if self._echo:
2002 stats = context._get_cache_stats() + " (insertmanyvalues)"
2003
2004 preserve_rowcount = context.execution_options.get(
2005 "preserve_rowcount", False
2006 )
2007 rowcount = 0
2008
2009 for imv_batch in dialect._deliver_insertmanyvalues_batches(
2010 self,
2011 cursor,
2012 str_statement,
2013 effective_parameters,
2014 generic_setinputsizes,
2015 context,
2016 ):
2017 if imv_batch.processed_setinputsizes:
2018 try:
2019 dialect.do_set_input_sizes(
2020 context.cursor,
2021 imv_batch.processed_setinputsizes,
2022 context,
2023 )
2024 except BaseException as e:
2025 self._handle_dbapi_exception(

Callers 1

_execute_contextMethod · 0.95

Calls 12

_log_infoMethod · 0.95
_repr_paramsMethod · 0.80
_get_cache_statsMethod · 0.45
getMethod · 0.45
do_set_input_sizesMethod · 0.45
do_executeMethod · 0.45
after_cursor_executeMethod · 0.45
post_execMethod · 0.45
_setup_result_proxyMethod · 0.45

Tested by

no test coverage detected