Skip to content

ENH: Add dtype to read sql to be consistent with read_sql_query #50797

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 5 commits into from
Jan 20, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 17, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Came across this, seemed odd to me that one supports it but not the other

@phofl phofl added IO SQL to_sql, read_sql, read_sql_query API - Consistency Internal Consistency of API/Behavior labels Jan 17, 2023
@@ -659,6 +668,7 @@ def read_sql(
parse_dates=parse_dates,
chunksize=chunksize,
use_nullable_dtypes=use_nullable_dtypes,
dtype=dtype,
Copy link
Member

Choose a reason for hiding this comment

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

How does this interact with use_nullable_dtypes when dtype is not a nullable type?

Copy link
Member Author

Choose a reason for hiding this comment

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

We should add tests for this :)

Right now we are casting to nullable and then apply astype (that's how it was implemented before as well). But I don't think that we have any tests covering this

Copy link
Member

Choose a reason for hiding this comment

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

Yeah would be good to add tests for this case. IIRC read_csv or a similar reader had a similar thing. This should hopefully operate similarly

Copy link
Member Author

Choose a reason for hiding this comment

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

added

@mroeschke mroeschke added this to the 2.0 milestone Jan 20, 2023
@mroeschke mroeschke merged commit 69a8150 into pandas-dev:main Jan 20, 2023
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the read_sql_dtyoe branch January 21, 2023 01:32
pooja-subramaniam pushed a commit to pooja-subramaniam/pandas that referenced this pull request Jan 25, 2023
…as-dev#50797)

* ENH: Add dtype to read sql to be consistent with read_sql_query

* Add gh ref

* Fix docstring

* Add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants