Skip to content

Commit a60cb16

Browse files
luke396phofl
authored andcommitted
DEPR: ADD FutureWarning for pandas.io.execute (pandas-dev#50676)
1 parent 00c0f12 commit a60cb16

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

doc/source/whatsnew/v2.0.0.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,10 @@ Other API changes
556556
Deprecations
557557
~~~~~~~~~~~~
558558
- 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`)
559+
- Deprecated :func:`pandas.io.sql.execute`(:issue:`50185`)
560+
-
559561

560562
.. ---------------------------------------------------------------------------
561-
562563
.. _whatsnew_200.prior_deprecations:
563564

564565
Removal of prior version deprecations/changes

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

+10
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,16 @@ 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+
# GH50185
673+
with tm.assert_produces_warning(
674+
FutureWarning,
675+
match="`pandas.io.sql.execute` is deprecated and "
676+
"will be removed in the future version.",
677+
):
678+
sql.execute("select * from iris", sqlite_buildin_iris)
679+
680+
671681
class MixInBase:
672682
def teardown_method(self):
673683
# if setup fails, there may not be a connection to close.

0 commit comments

Comments
 (0)