Skip to content

Commit 0c6c029

Browse files
author
luke
committed
add-FutureWarning-pandas.io.sql.execute
1 parent 76c39d5 commit 0c6c029

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

doc/source/whatsnew/v2.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ Other API changes
510510
Deprecations
511511
~~~~~~~~~~~~
512512
- Deprecated argument ``infer_datetime_format`` in :func:`to_datetime` and :func:`read_csv`, as a strict version of it is now the default (:issue:`48621`)
513-
513+
- Deprecated :func:`pandas.io.sql.execute`(:issue:`50185`)
514514
.. ---------------------------------------------------------------------------
515515
516516
.. _whatsnew_200.prior_deprecations:

pandas/io/sql.py

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ def execute(sql, con, params=None):
201201
-------
202202
Results Iterable
203203
"""
204+
warnings.warn(
205+
"`pandas.io.sql.execute` is deprecated and "
206+
"will be removed in the future version.",
207+
FutureWarning,
208+
stacklevel=find_stack_level(),
209+
) # GH50185
204210
sqlalchemy = import_optional_dependency("sqlalchemy", errors="ignore")
205211

206212
if sqlalchemy is not None and isinstance(con, (str, sqlalchemy.engine.Engine)):

pandas/tests/io/test_sql.py

+9
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,15 @@ def test_execute_typeerror(sqlite_iris_engine):
668668
sql.execute("select * from iris", sqlite_iris_engine)
669669

670670

671+
def test_execute_deprecated(sqlite_buildin_iris):
672+
with tm.assert_produces_warning(
673+
FutureWarning,
674+
match="`pandas.io.sql.execute` is deprecated and "
675+
"will be removed in the future version.",
676+
):
677+
sql.execute("select * from iris", sqlite_buildin_iris)
678+
679+
671680
class MixInBase:
672681
def teardown_method(self):
673682
# if setup fails, there may not be a connection to close.

0 commit comments

Comments
 (0)