Skip to content

ENH: sql support for NaN/NaT conversions #2754

Closed
@jreback

Description

@jreback

UPDATE from @jorisvandenbossche:

Overview of current status writing nan values (see also tests added in #7100):

  • For MySQL using pymysql/MySQLdb nothing works: you get message Unknown column 'nan' in 'field list' (see also eg http://stackoverflow.com/questions/23353732/python-pandas-write-to-sql-with-nan-values)
  • Numeric columns:
    • working for sqlite and postgres
    • Only full NaN columns stay None in sqlite
  • Object columns (eg strings)
    • for postgresql: NaN is converted to the string u'NaN', which is not really what we want
    • for sqlite it is returned as None
  • NaT:
    • postgresql: gives error on inserting "0001-255-255T00:00:00"
    • sqlite3: writing works, but reading it with query returns '-001--1--1 -1:-1:-1.-00001'
  • MSSQL: not working with message "The supplied value is not a valid instance of data type float", see Write Null values to mssql table #8088 for more details

not sure exactly what sql expects (Nones?) rather than np.nan (or NaT)

https://groups.google.com/forum/?fromgroups#!topic/pydata/lxhnFtuzvWQ

also provide pandas datetime64[ns], instead of datetime/date types
#3532

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsIO DataIO issues that don't fit into a more specific labelIO SQLto_sql, read_sql, read_sql_query

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions