libsql icon indicating copy to clipboard operation
libsql copied to clipboard

Treat ,, as NULL ,"", as empty string when importing CSV using sqlite shell

Open justjake opened this issue 1 year ago • 0 comments

I am trying to copy data from Postgres to libsql using the CSV format. SQLite already supports CSV imports and has good throughput, but has a major issue with CSV handling: SQLite does not respect the Postgres convention that a totally empty field ,, is NULL, and that a quoted empty field ,"", is '' EMPTY STRING - and does not seem to allow any configuration to set other sentinel values like '\N' or 'NULL' as null either.

Instead, because its the javascript of databases, it will insert an EMPTY STRING into an INTEGER column, and worse there’s no way to disambiguate nullable TEXT columns without referring to the original CSV file.

There’s a bunch of complaints on the SQLite forum about this, and no movement, although i think there are a few extensions. I see someone imported CSV import for the turso CLI, but it just delegates this to sqlite

justjake avatar Mar 14 '24 13:03 justjake