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: to_sql fails with datetime.time values with sqlite fallback mode #8341

Closed
jorisvandenbossche opened this issue Sep 21, 2014 · 8 comments
Labels
IO SQL to_sql, read_sql, read_sql_query
Milestone

Comments

@jorisvandenbossche
Copy link
Member

Columns of datetime.time were not yet supported in sqlite fallback mode (as noted in #7567, and do work for sqlalchemy), but it now seems to fail silently with master (instead of raising an error).

Using:

import sqlite3
con = sqlite3.connect(':memory:')
dt = pd.date_range('2014-01-01', periods=10, freq='10h')
df = pd.DataFrame({'date':dt.date, 'time':dt.time})
df.to_sql('test_datetime', con, index=False, if_exists='replace')

gives:

In [37]: pd.read_sql_query('select * from test_datetime', con)
Out[37]: 
Empty DataFrame
Columns: [date, time]
Index: []
@jorisvandenbossche jorisvandenbossche added the IO SQL to_sql, read_sql, read_sql_query label Sep 21, 2014
@jorisvandenbossche jorisvandenbossche added this to the 0.15.0 milestone Sep 21, 2014
@jreback
Copy link
Contributor

jreback commented Sep 30, 2014

@jorisvandenbossche pls move any sql issues you don't think can get to in next couple of days to 0.15.1 pls.

@jreback
Copy link
Contributor

jreback commented Oct 2, 2014

push?

@jorisvandenbossche
Copy link
Member Author

@jreback I will have a look at the sql issues this evening and push if necessary

@jreback
Copy link
Contributor

jreback commented Oct 2, 2014

@jorisvandenbossche gr8 thanks

@jorisvandenbossche
Copy link
Member Author

I will try to look at it this weekend

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.16, 0.15.0 Oct 5, 2014
@jorisvandenbossche jorisvandenbossche changed the title BUG: to_sql fails silently with column of datetime.time values with sqlite fallback mode BUG: to_sql fails with datetime.time values with sqlite fallback mode Oct 5, 2014
@jorisvandenbossche
Copy link
Member Author

See #8470 to fix the fact it fails silently. So now it will again just raise a InterfaceError: Error binding parameter 0 - probably unsupported type.
Changed title of issue to reflect that.

@jreback jreback modified the milestones: 0.16, 0.15.1 Oct 7, 2014
@jorisvandenbossche
Copy link
Member Author

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@jorisvandenbossche jorisvandenbossche modified the milestones: Someday, Next Major Release Aug 11, 2015
jorisvandenbossche pushed a commit that referenced this issue Feb 24, 2016
I'm proposing a solution to #8341    As @jorisvandenbossche suggested,
I use a sqlite3 adapter to transform `datetime.time` objects into
string (`hh:mm:ss.ffffff`, as this what sqlalchemy... I think?)    I
added a test in the class `_TestSQLApi`, so that the solution is
tested with both sqlalchemy and the sqlite3 fallback. Thus, the result
should be consistent.

Author: Nicolas Bonnotte <nicolas.bonnotte@gmail.com>

Closes #11547 from nbonnotte/sqlite-to_sql-time and squashes the following commits:

8d449c5 [Nicolas Bonnotte] BUG: to_sql with datetime.time values with sqlite, #8341
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.18.0, Someday Feb 24, 2016
@jorisvandenbossche
Copy link
Member Author

Closed by #11547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

No branches or pull requests

2 participants