Skip to content
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

DEPR: Positional arguments in to_sql except name #54397

Merged
merged 16 commits into from
Aug 10, 2023
Merged

DEPR: Positional arguments in to_sql except name #54397

merged 16 commits into from
Aug 10, 2023

Conversation

rmhowe425
Copy link
Contributor

@rmhowe425 rmhowe425 commented Aug 4, 2023

@rmhowe425 rmhowe425 marked this pull request as draft August 4, 2023 01:22
@rmhowe425 rmhowe425 changed the title ENH: Updated method header and whatsnew file ENH: Positional arguments in to_* I/O methods Aug 4, 2023
@rmhowe425 rmhowe425 marked this pull request as ready for review August 4, 2023 11:48
pandas/core/generic.py Outdated Show resolved Hide resolved
@mroeschke mroeschke added the IO SQL to_sql, read_sql, read_sql_query label Aug 4, 2023
pandas/core/generic.py Outdated Show resolved Hide resolved
@rmhowe425
Copy link
Contributor Author

@mroeschke pinging on green

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

There should also be a single test that specifying con as a positional argument raises a FutureWarning

@rmhowe425
Copy link
Contributor Author

@mroeschke pinging on green

@mroeschke mroeschke changed the title ENH: Positional arguments in to_* I/O methods DEPR: Positional arguments in to_sql except name Aug 10, 2023
@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Aug 10, 2023
@mroeschke mroeschke added this to the 2.1 milestone Aug 10, 2023
@mroeschke mroeschke merged commit f935543 into pandas-dev:main Aug 10, 2023
36 checks passed
@mroeschke
Copy link
Member

Thanks @rmhowe425

@rmhowe425 rmhowe425 deleted the dev/keyword/to_sql branch August 10, 2023 18:34
@rmhowe425 rmhowe425 restored the dev/keyword/to_sql branch August 10, 2023 18:36
mroeschke pushed a commit to mroeschke/pandas that referenced this pull request Aug 18, 2023
* Updated method header and whatsnew file

* Updated unit tests to use keyword argument for con parameter.

* Updating unit tests and implementation.

* Updated documentation and unit tests.

* Updating documentation and fixing unit tests.

* Updating documentation.

* Updating documentation and fixing failing unit tests.

* Updating documentation and unit tests.

* Updating implementation based on reviewer feedback.

* Updating implementation to allow 'self' to be a positional arg.

* Deprecating con positional arg in new test case.

* Fixing typo

* Fixing typo
Comment on lines +2798 to 2801
@deprecate_nonkeyword_arguments(
version="3.0", allowed_args=["self", "name"], name="to_sql"
)
def to_sql(
Copy link
Member

Choose a reason for hiding this comment

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

It might make sense to allow con as positional as well?
(certainly given that it is a required argument, quite self-descriptive (eg not a boolean argument), and that this pattern is widely used in our own docs)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I can see that being reasonable. I don't have super strong feelings about it though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if I need to update the PR!

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @jorisvandenbossche, con is a weird name, I'd allow this to be positional as well (personally never specified it). Opened #54749 and PR is incoming, this should go into 2.1

df = DataFrame([{"A": 1, "B": 2, "C": 3}, {"A": 1, "B": 2, "C": 3}])

with tm.assert_produces_warning(FutureWarning, match=msg):
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.

should this use e.g. tm.ensure_clean? i think this may be leaving behind an "example" file after local test runs

@rmhowe425 rmhowe425 deleted the dev/keyword/to_sql branch February 17, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants