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

CLN: Removed the flavor parameter in DataFrame.to_sql #13611

Merged

Conversation

gfyoung
Copy link
Member

@gfyoung gfyoung commented Jul 11, 2016

Deprecated in 0.14.0, so way, way overdue.

@jorisvandenbossche
Copy link
Member

@gfyoung We cannot just remove the flavor keyword. It was only deprecated for 'mysql', not for 'sqlite' (wihch is a pitty ..)

@jorisvandenbossche jorisvandenbossche added IO SQL to_sql, read_sql, read_sql_query Deprecate Functionality to remove in pandas labels Jul 11, 2016
@jorisvandenbossche jorisvandenbossche added this to the 0.19.0 milestone Jul 11, 2016
@gfyoung
Copy link
Member Author

gfyoung commented Jul 11, 2016

@jorisvandenbossche : But the argument accepts only one value now (sqlite), so why not remove it? Are we planning to add new functionality to it in the future? Judging from the documentation, I did not get that impression, as we seem to be relegating more of the functionality to SQLAlchemy (it doesn't even respect the parameter if SQLAlchemy is available).

@jorisvandenbossche
Copy link
Member

No, we are certainly not planning that. And in retrospect, it's a pitty that we didn't deprecate the full flavor keyword. But we have to deal with it now. I think we should give a nice error/warning message in case of flavor='sqlite'. So either deprecated that, or 'remove' it but still capture it's usage to display a more informative error message.

@gfyoung
Copy link
Member Author

gfyoung commented Jul 11, 2016

@jorisvandenbossche : How does adding a **kwargs parameter sound? Then we can still accept it and warn about it if the user passes it in.

@jorisvandenbossche
Copy link
Member

@gfyoung That sounds good!

@gfyoung
Copy link
Member Author

gfyoung commented Jul 12, 2016

@jorisvandenbossche : added *args and **kwargs along with a validation function AND skipped all of the test suite that relied on the flavor="mysql" connection. However, I would like to add a test afterwards to make sure the flavor parameter is properly deprecated without these functions getting abused, but I just want to make sure these initial changes appeal the Travis.

@codecov-io
Copy link

codecov-io commented Jul 12, 2016

Current coverage is 84.37%

No coverage report found for master at 4c9ae94.

Powered by Codecov. Last updated by 4c9ae94...74e8975

def to_sql(self, name, con, flavor='sqlite', schema=None, if_exists='fail',
index=True, index_label=None, chunksize=None, dtype=None):
def to_sql(self, name, con, schema=None, if_exists='fail', index=True,
index_label=None, chunksize=None, dtype=None, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the *args are needed here. If people were using positional kwargs, the current deprecation will not work anyways (as schema will catch the flavor)

Copy link
Member

Choose a reason for hiding this comment

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

Alternative is to keep flavor in the signature, but change it to None, so we can detect when people set it to 'sqlite' themselves. That solves the positional kwarg problem, but of course pollutes the signature a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Argh...good point. I think I'll just remove the '*args' parameter and not pollute the signature.

@gfyoung
Copy link
Member Author

gfyoung commented Jul 14, 2016

@jreback , @jorisvandenbossche : Updated the signatures, and Travis is still giving the green light. Ready to merge if there are no other concerns.

@jorisvandenbossche
Copy link
Member

@gfyoung yeah, I saw your ping, but I also have other work :-)

I worry a bit about the usage of flavor as positional arg .. We actually used it like at some places in the tests I saw in the diff. But it is difficult to judge whether this is used like that by users (a quick stackoverflow search didn't turn anything up).
It would be the safer option to leave it in the signature I think until we actually remove it.

@gfyoung
Copy link
Member Author

gfyoung commented Jul 14, 2016

Yeah...that is a fair point. Original purpose was to just remove the 'mysql' option, so let me scale this PR back down to that.

@jorisvandenbossche
Copy link
Member

@gfyoung Yes, but I think it would still be good to deprecated the flavor arg, so we can remove it later on. So if you want to do that, I don't it is a large change from what you have now, it's just adding it back in the signature and replacing the kwarg validator with only the deprecation part of it

@gfyoung gfyoung force-pushed the to-sql-flavor-remove branch 2 times, most recently from b28152c to 4dd32bb Compare July 15, 2016 08:35
@gfyoung
Copy link
Member Author

gfyoung commented Jul 15, 2016

@jorisvandenbossche : Updated the signature and put the flavor parameter back. However, it was tricky to issue warnings because flavor is a keyword with default value as "sqlite" in MOST cases. As we don't want to punish users who don't pass it in, and since it has no effect anymore, I changed the default value for flavor in ALL signatures to None. Travis is happy with this change, so ready to merge if there are no other concerns.

@gfyoung
Copy link
Member Author

gfyoung commented Jul 15, 2016

@jreback, @jorisvandenbossche : rebased and Travis is still happy - ready to merge if there are no other concerns.

@@ -492,6 +492,7 @@ Deprecations
- ``Categorical.reshape`` has been deprecated and will be removed in a subsequent release (:issue:`12882`)
- ``Series.reshape`` has been deprecated and will be removed in a subsequent release (:issue:`12882`)

- ``DataFrame.to_sql()`` has deprecated the ``flavor`` parameter (:issue:`13611`)
Copy link
Member

Choose a reason for hiding this comment

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

Can you emphasize that is is a superfluous keyword (so no reason to use it), since sqlite is the only supported connection when not using sqlalchemy?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@jorisvandenbossche
Copy link
Member

@gfyoung Looks good! (using flavor=None is perfect for detecting if user has specified it themselves) Few minor comments.

@gfyoung
Copy link
Member Author

gfyoung commented Jul 16, 2016

@jorisvandenbossche : made the requested doc changes (no need to run tests, hence the [ci skip], so ready to merge if there are no other concerns.

@gfyoung gfyoung force-pushed the to-sql-flavor-remove branch 4 times, most recently from 573646a to 4562ec4 Compare July 19, 2016 02:11
@gfyoung
Copy link
Member Author

gfyoung commented Jul 19, 2016

@jorisvandenbossche : any updates on this?

@jorisvandenbossche
Copy link
Member

Yes, merging! Thanks a lot

@jorisvandenbossche jorisvandenbossche merged commit 8acfad3 into pandas-dev:master Jul 19, 2016
@gfyoung gfyoung deleted the to-sql-flavor-remove branch July 20, 2016 00:46
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.

3 participants