MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / exec_driver_sql

Method exec_driver_sql

lib/sqlalchemy/engine/base.py:1692–1765  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers 15

do_rollback_twophaseMethod · 0.45
do_commit_twophaseMethod · 0.45
_pg_create_dbFunction · 0.45
_pg_drop_dbFunction · 0.45
prepare_for_drop_tablesFunction · 0.45
_oracle_create_dbFunction · 0.45

Calls 3

_execute_contextMethod · 0.95
_distill_raw_paramsFunction · 0.85
merge_withMethod · 0.45

Tested by 15

_assert_result_strMethod · 0.36
test_cols_driver_colsMethod · 0.36
test_ss_cursor_statusMethod · 0.36
test_conn_optionMethod · 0.36
_test_index_criteriaMethod · 0.36
test_raw_sql_rowcountMethod · 0.36
test_freezeMethod · 0.36
test_fetchone_til_endMethod · 0.36
test_lenMethod · 0.36