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,
)
| 1714 | return ret |
| 1715 | |
| 1716 | def exec_driver_sql( |
| 1717 | self, |
| 1718 | statement: str, |
| 1719 | parameters: Optional[_DBAPIAnyExecuteParams] = None, |
| 1720 | execution_options: Optional[CoreExecuteOptionsParameter] = None, |
| 1721 | ) -> CursorResult[Any]: |
| 1722 | r"""Executes a string SQL statement on the DBAPI cursor directly, |
| 1723 | without any SQL compilation steps. |
| 1724 | |
| 1725 | This can be used to pass any string directly to the |
| 1726 | ``cursor.execute()`` method of the DBAPI in use. |
| 1727 | |
| 1728 | :param statement: The statement str to be executed. Bound parameters |
| 1729 | must use the underlying DBAPI's paramstyle, such as "qmark", |
| 1730 | "pyformat", "format", etc. |
| 1731 | |
| 1732 | :param parameters: represent bound parameter values to be used in the |
| 1733 | execution. The format is one of: a dictionary of named parameters, |
| 1734 | a tuple of positional parameters, or a list containing either |
| 1735 | dictionaries or tuples for multiple-execute support. |
| 1736 | |
| 1737 | :return: a :class:`_engine.CursorResult`. |
| 1738 | |
| 1739 | E.g. multiple dictionaries:: |
| 1740 | |
| 1741 | |
| 1742 | conn.exec_driver_sql( |
| 1743 | "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)", |
| 1744 | [{"id": 1, "value": "v1"}, {"id": 2, "value": "v2"}], |
| 1745 | ) |
| 1746 | |
| 1747 | Single dictionary:: |
| 1748 | |
| 1749 | conn.exec_driver_sql( |
| 1750 | "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)", |
| 1751 | dict(id=1, value="v1"), |
| 1752 | ) |
| 1753 | |
| 1754 | Single tuple:: |
| 1755 | |
| 1756 | conn.exec_driver_sql( |
| 1757 | "INSERT INTO table (id, value) VALUES (?, ?)", (1, "v1") |
| 1758 | ) |
| 1759 | |
| 1760 | .. note:: The :meth:`_engine.Connection.exec_driver_sql` method does |
| 1761 | not participate in the |
| 1762 | :meth:`_events.ConnectionEvents.before_execute` and |
| 1763 | :meth:`_events.ConnectionEvents.after_execute` events. To |
| 1764 | intercept calls to :meth:`_engine.Connection.exec_driver_sql`, use |
| 1765 | :meth:`_events.ConnectionEvents.before_cursor_execute` and |
| 1766 | :meth:`_events.ConnectionEvents.after_cursor_execute`. |
| 1767 | |
| 1768 | .. seealso:: |
| 1769 | |
| 1770 | :pep:`249` |
| 1771 | |
| 1772 | """ |
| 1773 |