Skip to content

Revert deprecation of con as keyword only arg #54750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2801,7 +2801,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
df.to_sql("example", self.conn)

Don't think this is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d like to keep it to keep a test that this does not raise close by

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. I think you'll need a if_exists="replace" below then.


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

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