Skip to content

BUG: to_sql fails for pyarrow date dtype (#53854) #53856

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 3 commits into from
Jun 26, 2023

Conversation

NMAC427
Copy link
Contributor

@NMAC427 NMAC427 commented Jun 26, 2023

@mroeschke mroeschke added IO SQL to_sql, read_sql, read_sql_query Arrow pyarrow functionality labels Jun 26, 2023
@mroeschke mroeschke modified the milestone: 2.1 Jun 26, 2023
pandas/io/sql.py Outdated

if pa.types.is_date(ser.dtype.pyarrow_dtype):
# GH#53854 to_pydatetime not supported for pyarrow date dtypes
d = ser._values.astype(object)
Copy link
Member

Choose a reason for hiding this comment

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

Could you use ser._values.to_numpy(dtype=object)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed a new commit with the requested changes.

@mroeschke mroeschke added this to the 2.1 milestone Jun 26, 2023
@mroeschke mroeschke merged commit b126638 into pandas-dev:main Jun 26, 2023
@mroeschke
Copy link
Member

Thanks @NMAC427

Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…ev#53856)

* BUG: to_sql fails for pyarrow date dtype (pandas-dev#53854)

* use ArrowExtensionArray.to_numpy instead of ArrowExtensionArray.astype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: to_sql fails with arrow date column
2 participants