简体   繁体   中英

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.

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

cursor.execute(insertinfo_2)

sqlite3.OperationalError: no such column: 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.

If your db column do not support nan or inf for int or real value do not insert these to db.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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