r"""Executes a string SQL statement on the DBAPI cursor directly, without any SQL compilation steps. This can be used to pass any string directly to the ``cursor.execute()`` method of the DBAPI in use. :param statement: The statement str to be executed. Bound para
(
self,
statement: str,
parameters: Optional[_DBAPIAnyExecuteParams] = None,
execution_options: Optional[CoreExecuteOptionsParameter] = None,
)
| 1690 | return ret |
| 1691 | |
| 1692 | def exec_driver_sql( |
| 1693 | self, |
| 1694 | statement: str, |
| 1695 | parameters: Optional[_DBAPIAnyExecuteParams] = None, |
| 1696 | execution_options: Optional[CoreExecuteOptionsParameter] = None, |
| 1697 | ) -> CursorResult[Unpack[TupleAny]]: |
| 1698 | r"""Executes a string SQL statement on the DBAPI cursor directly, |
| 1699 | without any SQL compilation steps. |
| 1700 | |
| 1701 | This can be used to pass any string directly to the |
| 1702 | ``cursor.execute()`` method of the DBAPI in use. |
| 1703 | |
| 1704 | :param statement: The statement str to be executed. Bound parameters |
| 1705 | must use the underlying DBAPI's paramstyle, such as "qmark", |
| 1706 | "pyformat", "format", etc. |
| 1707 | |
| 1708 | :param parameters: represent bound parameter values to be used in the |
| 1709 | execution. The format is one of: a dictionary of named parameters, |
| 1710 | a tuple of positional parameters, or a list containing either |
| 1711 | dictionaries or tuples for multiple-execute support. |
| 1712 | |
| 1713 | :return: a :class:`_engine.CursorResult`. |
| 1714 | |
| 1715 | E.g. multiple dictionaries:: |
| 1716 | |
| 1717 | |
| 1718 | conn.exec_driver_sql( |
| 1719 | "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)", |
| 1720 | [{"id": 1, "value": "v1"}, {"id": 2, "value": "v2"}], |
| 1721 | ) |
| 1722 | |
| 1723 | Single dictionary:: |
| 1724 | |
| 1725 | conn.exec_driver_sql( |
| 1726 | "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)", |
| 1727 | dict(id=1, value="v1"), |
| 1728 | ) |
| 1729 | |
| 1730 | Single tuple:: |
| 1731 | |
| 1732 | conn.exec_driver_sql( |
| 1733 | "INSERT INTO table (id, value) VALUES (?, ?)", (1, "v1") |
| 1734 | ) |
| 1735 | |
| 1736 | .. note:: The :meth:`_engine.Connection.exec_driver_sql` method does |
| 1737 | not participate in the |
| 1738 | :meth:`_events.ConnectionEvents.before_execute` and |
| 1739 | :meth:`_events.ConnectionEvents.after_execute` events. To |
| 1740 | intercept calls to :meth:`_engine.Connection.exec_driver_sql`, use |
| 1741 | :meth:`_events.ConnectionEvents.before_cursor_execute` and |
| 1742 | :meth:`_events.ConnectionEvents.after_cursor_execute`. |
| 1743 | |
| 1744 | .. seealso:: |
| 1745 | |
| 1746 | :pep:`249` |
| 1747 | |
| 1748 | """ |
| 1749 |