[英]SQLite3 OperationalError: Table XYZ has no column named ABC
[英]sqlite3 create table - OperationalError: no such column: nan
脚本可以正确插入任意数量的表,但以下表除外,这些表与已成功创建的其他表的格式相同。 我不确定它为什么要识别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()
这是我得到的错误:
文件“create_db.py”,第 67 行,在
cursor.execute(insertinfo_2)
sqlite3.OperationalError:没有这样的列:nan
当我将 NAN 值插入到 db 时出现此错误,我们的一些操作是在插入到 db 之前将 integer 值转换为 nan。
如果您的 db 列不支持 nan 或 inf 用于 int 或 real 值,请不要将它们插入 db。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.