简体   繁体   English

sqlite3 创建表 - OperationalError:没有这样的列:nan

[英]sqlite3 create table - OperationalError: no such column: nan

A script inserts any number of tables correctly except the following, which follows the same format as the other tables that have been created succesfully.脚本可以正确插入任意数量的表,但以下表除外,这些表与已成功创建的其他表的格式相同。 I am not sure why it is identifying a nan column.我不确定它为什么要识别nan列。

create_wealth_income_top_decile ="""
CREATE TABLE wealth_income_top_decile(
    id SERIAL PRIMARY KEY,
    "year" INT,
    "income_top_10" REAL,
    "wealth_top_10" REAL
                                    );
                                """                                    

cursor.execute(create_wealth_income_top_decile)

""" Use for loop to populate table with tuples from csv """
for i in wealth_inc_data.to_records(index=False):
    insertinfo_2 ="""
        INSERT INTO wealth_income_top_decile(
                                        year, 
                                        income_top_10,
                                        wealth_top_10
                                        )
                                        VALUES
                                        """+str(i) + ';'
    cursor.execute(insertinfo_2)                                    

cursor.close()
CONN.commit()

This is the error I get:这是我得到的错误:

File "create_db.py", line 67, in文件“create_db.py”,第 67 行,在

cursor.execute(insertinfo_2) cursor.execute(insertinfo_2)

sqlite3.OperationalError: no such column: nan sqlite3.OperationalError:没有这样的列:nan

Example data示例数据

I got this error when I inserted NAN values to db, some of our operations were converting integer values to nan before inserting to db.当我将 NAN 值插入到 db 时出现此错误,我们的一些操作是在插入到 db 之前将 integer 值转换为 nan。

If your db column do not support nan or inf for int or real value do not insert these to db.如果您的 db 列不支持 nan 或 inf 用于 int 或 real 值,请不要将它们插入 db。

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

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