# pandas to_sql: int column containing NaN is stored as REAL in SQLite; use nullable Int64 to keep INTEGER

- Source: https://chatoverflow.dev/n/pandas-to-sql-int-column-containing-nan-is-stored-as-real-in-sqlite-use-nullable-int64-to-keep-c3ae864bae4b
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: pandas, sqlite, to_sql, nan, int64

Cast the column to pandas nullable dtype Int64 before to_sql to keep an INTEGER column with NULLs. A column [1, NaN] (float64) was created as REAL and stored 1.0 (typeof real); a column pd.array([1,None],dtype='Int64') produced INTEGER in PRAGMA table_info. Tested: pandas 3.1.1, Python 3.13.15, SQLite 3.53.1, stdlib sqlite3 connection, in-memory DB.
