Create an :class:`.ExecutionContext` and execute, returning a :class:`_engine.CursorResult`.
(
self,
dialect: Dialect,
constructor: Callable[..., ExecutionContext],
statement: Union[str, Compiled],
parameters: Optional[_AnyMultiExecuteParams],
execution_options: _ExecuteOptions,
*args: Any,
**kw: Any,
)
| 1765 | return ret |
| 1766 | |
| 1767 | def _execute_context( |
| 1768 | self, |
| 1769 | dialect: Dialect, |
| 1770 | constructor: Callable[..., ExecutionContext], |
| 1771 | statement: Union[str, Compiled], |
| 1772 | parameters: Optional[_AnyMultiExecuteParams], |
| 1773 | execution_options: _ExecuteOptions, |
| 1774 | *args: Any, |
| 1775 | **kw: Any, |
| 1776 | ) -> CursorResult[Unpack[TupleAny]]: |
| 1777 | """Create an :class:`.ExecutionContext` and execute, returning |
| 1778 | a :class:`_engine.CursorResult`.""" |
| 1779 | |
| 1780 | if execution_options: |
| 1781 | yp = execution_options.get("yield_per", None) |
| 1782 | if yp: |
| 1783 | execution_options = execution_options.union( |
| 1784 | {"stream_results": True, "max_row_buffer": yp} |
| 1785 | ) |
| 1786 | try: |
| 1787 | conn = self._dbapi_connection |
| 1788 | if conn is None: |
| 1789 | conn = self._revalidate_connection() |
| 1790 | |
| 1791 | context = constructor( |
| 1792 | dialect, self, conn, execution_options, *args, **kw |
| 1793 | ) |
| 1794 | except (exc.PendingRollbackError, exc.ResourceClosedError): |
| 1795 | raise |
| 1796 | except BaseException as e: |
| 1797 | self._handle_dbapi_exception( |
| 1798 | e, str(statement), parameters, None, None |
| 1799 | ) |
| 1800 | |
| 1801 | if ( |
| 1802 | self._transaction |
| 1803 | and not self._transaction.is_active |
| 1804 | or ( |
| 1805 | self._nested_transaction |
| 1806 | and not self._nested_transaction.is_active |
| 1807 | ) |
| 1808 | ): |
| 1809 | self._invalid_transaction() |
| 1810 | |
| 1811 | elif self._trans_context_manager: |
| 1812 | TransactionalContext._trans_ctx_check(self) |
| 1813 | |
| 1814 | if self._transaction is None: |
| 1815 | self._autobegin() |
| 1816 | |
| 1817 | context.pre_exec() |
| 1818 | |
| 1819 | if context.execute_style is ExecuteStyle.INSERTMANYVALUES: |
| 1820 | return self._exec_insertmany_context(dialect, context) |
| 1821 | else: |
| 1822 | return self._exec_single_context( |
| 1823 | dialect, context, statement, parameters |
| 1824 | ) |
no test coverage detected