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

BUG: SQLAlchemy Date() classes still written as DateTimes #39703

Open
2 of 3 tasks
EmperorArthur opened this issue Feb 9, 2021 · 0 comments
Open
2 of 3 tasks

BUG: SQLAlchemy Date() classes still written as DateTimes #39703

EmperorArthur opened this issue Feb 9, 2021 · 0 comments
Labels
Bug datetime.date stdlib datetime.date support IO SQL to_sql, read_sql, read_sql_query

Comments

@EmperorArthur
Copy link

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample

from sqlalchemy import create_engine, Date
from pandas import DataFrame
from datetime import datetime

df = DataFrame([{'test': datetime.now()}])
df.to_sql(
'test_table',
create_engine('sqlite:///foo.db'),
dtype={'test': Date()}
)

Problem description

The above code works, as far as successfully storing the data in the database.
However, it can not be read back out again. The entire datetime is stored, instead of just the date!

Python complains and refuses to read the table.

Expected Output

Dates are properly stored if passed as an SQLAlchemy dtype.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 7d32926
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-65-generic
Version : #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.2
numpy : 1.20.1
pytz : 2021.1
dateutil : 2.8.1
pip : 20.2.4
setuptools : 44.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.11.3
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.8.5
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : None
odfpy : None
openpyxl : 3.0.6
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.0
sqlalchemy : 1.3.23
tables : None
tabulate : None
xarray : 0.16.1
xlrd : None
xlwt : None
numba : None

@EmperorArthur EmperorArthur added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 9, 2021
@jbrockmendel jbrockmendel added datetime.date stdlib datetime.date support IO SQL to_sql, read_sql, read_sql_query labels Jun 5, 2021
@mroeschke mroeschke removed the Needs Triage Issue that has not been reviewed by a pandas team member label Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug datetime.date stdlib datetime.date support IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

No branches or pull requests

3 participants