[英]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.