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: Regression how datetime64[ns] is saved in sqlite table #54877

Closed
2 of 3 tasks
maximiliank opened this issue Aug 30, 2023 · 1 comment · Fixed by #54985
Closed
2 of 3 tasks

BUG: Regression how datetime64[ns] is saved in sqlite table #54877

maximiliank opened this issue Aug 30, 2023 · 1 comment · Fixed by #54985
Labels
Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@maximiliank
Copy link

Pandas version checks

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

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

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
import datetime as dt
import sqlite3

df=pd.DataFrame({'t':[dt.datetime.now()]}, dtype='datetime64[ns]')
conn=sqlite3.connect('test.sqlite3')
df.to_sql('test', conn, if_exists='replace', index=False)
conn.close()

Issue Description

With pandas version 2.1.0 the content of the sqlite3 table is:

SELECT * FROM test;
1693426580

So it stores datetime64[ns] as epoch.

With pandas version < 2.1.0 the content would be a string:
2023-08-30 22:16:24.753962

Expected Behavior

Save the datetime64[ns] as string like in the previous pandas versions

Installed Versions

INSTALLED VERSIONS

commit : ba1cccd
python : 3.11.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.102.1-microsoft-standard-WSL2
Version : #1 SMP Wed Mar 2 00:30:59 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.1.0
numpy : 1.25.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 66.1.1
pip : 23.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@maximiliank maximiliank added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 30, 2023
@jorisvandenbossche jorisvandenbossche added Regression Functionality that used to work in a prior pandas version and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 31, 2023
@jorisvandenbossche jorisvandenbossche added this to the 2.1.1 milestone Aug 31, 2023
@phofl
Copy link
Member

phofl commented Sep 3, 2023

#53743 cc @lithomas1

visr added a commit to Deltares/Ribasim that referenced this issue Sep 12, 2023
A regression breaks writing timestamps to GeoPackage for us: pandas-dev/pandas#54877
visr added a commit to Deltares/Ribasim that referenced this issue Sep 12, 2023
A regression breaks writing timestamps to GeoPackage for us:
pandas-dev/pandas#54877

Found in
#586 (comment)
visr added a commit to Deltares/Ribasim that referenced this issue Sep 14, 2023
A regression breaks writing timestamps to GeoPackage for us:
pandas-dev/pandas#54877

Found in
#586 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants