Skip to content

Commit

Permalink
Backport PR pandas-dev#54750: Revert deprecation of con as keyword on…
Browse files Browse the repository at this point in the history
…ly arg
  • Loading branch information
phofl authored and meeseeksmachine committed Aug 26, 2023
1 parent 0c7a8b4 commit 2a9d31b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ Other Deprecations
- Deprecated the use of non-supported datetime64 and timedelta64 resolutions with :func:`pandas.array`. Supported resolutions are: "s", "ms", "us", "ns" resolutions (:issue:`53058`)
- Deprecated values ``"pad"``, ``"ffill"``, ``"bfill"``, ``"backfill"`` for :meth:`Series.interpolate` and :meth:`DataFrame.interpolate`, use ``obj.ffill()`` or ``obj.bfill()`` instead (:issue:`53581`)
- Deprecated the behavior of :meth:`Index.argmax`, :meth:`Index.argmin`, :meth:`Series.argmax`, :meth:`Series.argmin` with either all-NAs and ``skipna=True`` or any-NAs and ``skipna=False`` returning -1; in a future version this will raise ``ValueError`` (:issue:`33941`, :issue:`33942`)
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_sql` except ``name`` (:issue:`54229`)
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_sql` except ``name`` and ``con`` (:issue:`54229`)

.. ---------------------------------------------------------------------------
.. _whatsnew_210.performance:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ def to_hdf(

@final
@deprecate_nonkeyword_arguments(
version="3.0", allowed_args=["self", "name"], name="to_sql"
version="3.0", allowed_args=["self", "name", "con"], name="to_sql"
)
def to_sql(
self,
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2849,13 +2849,14 @@ def setup_driver(cls):
def test_keyword_deprecation(self):
# GH 54397
msg = (
"tarting with pandas version 3.0 all arguments of to_sql except for the "
"argument 'name' will be keyword-only."
"Starting with pandas version 3.0 all arguments of to_sql except for the "
"arguments 'name' and 'con' will be keyword-only."
)
df = DataFrame([{"A": 1, "B": 2, "C": 3}, {"A": 1, "B": 2, "C": 3}])
df.to_sql("example", self.conn)

with tm.assert_produces_warning(FutureWarning, match=msg):
df.to_sql("example", self.conn)
df.to_sql("example", self.conn, None, if_exists="replace")

def test_default_type_conversion(self):
df = sql.read_sql_table("types", self.conn)
Expand Down

0 comments on commit 2a9d31b

Please sign in to comment.