tags:

views:

141

answers:

2

Does the sqlite3 .import command used to import data from delimited text files append rows to existing content if the destination table is not empty, or does it clear the table first?

A: 

.import will INSERT the file's data into the table.

Nick D
+2  A: 

.import appends rows to existing data (if any), it does not overwrite the contents of the table.

$ echo "d|e|f" > testimport.txt


sqlite> create table testimport (col1, col2, col3);

sqlite> insert into testimport(col1,col2,col3) values ('a','b','c');

sqlite> select * from testimport;

a|b|c

sqlite> .import testimport.txt testimport

sqlite> select * from testimport;

a|b|c
d|e|f
Louis