We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
To import CSV files into SQLite, you can do this in your terminal:
sqlite3 mydatabase.db
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite> .import --csv mydata.csv table_name
If the table already exists and the field names don't match the header names, you can also skip the first row:
sqlite3 mydatabase.db
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite> .import --csv --skip 1 mydata.csv table_name
Importing the file again overwriting what is already in the table:
sqlite3 mydatabase.db
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite> begin;
sqlite> delete from table_name;
sqlite> .import --csv --skip 1 mydata.csv table_name
sqlite> commit;
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.