简体   繁体   English

尝试使用python将值插入MySQL表时出错

[英]error when trying to insert values into MySQL table with python

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: 进入mySQL数据库表,但我似乎有空值(NaN)的问题,因为我收到此错误:

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.. 我已经尝试在mySQL中使列可以为空,并且还制作所有文本字段,但仍然没有骰子..

The problem is that nan is not a valid value for a MySQL column. 问题是nan不是MySQL列的有效值。 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. 要实现此目的,请在脚本中添加一些逻辑,以将所有nan值更改为NULL字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM