I'm trying to insert this row of data (i parse from a list of tuples)
(0L, u'2012-11-06T16:23:36-05:00', 0L, None, 23759918L, u'baseline', u'0 to 100', nan, 105114L, 2009524L, True, u'charge', u'Charge')
into a mySQL database table, but i seem to have problems with the null value (NaN), because i receive this error:
OperationalError: (1054, "Unknown column 'nan' in 'field list'")
I've tried making columns nullable in mySQL, and also making all text fields, but still no dice..
Connector/Python does not support the old MySQL Server authentication methods, which means that MySQL versions prior to 4.1 will not work. On macOS x86_64 ARM: Python 3.7 is not supported with the c-ext implementation; note this is a non-default version of Python on macOS.
Create a dataframe by calling the pandas dataframe constructor and passing the python dict object as data. Invoke to_sql() method on the pandas dataframe instance and specify the table name and database connection. This creates a table in MySQL database server and populates it with the data from the pandas dataframe.
The problem is that nan
is not a valid value for a MySQL
column. It is complaining just about that. Your values string should be:
(0L, u'2012-11-06T16:23:36-05:00', 0L, None, 23759918L, u'baseline', u'0 to 100', null, 105114L, 2009524L, True, u'charge', u'Charge')
To achieve this, add some logic to your script to change all nan
values to NULL
string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With