On 15 Aug 2010, at 11:31pm, Peng Yu wrote: > $ cat file.txt > 1 eenie > 2 meenie > 3 miny > 4 mo > $cat main.sql > #!/usr/bin/env bash > > rm -f main.db > sqlite3 main.db < file.txt <<EOF
That cannot work: it would require a file with commands in and your file has data in. > create table test (id integer primary key, value text); > .separator "\t" > .import /dev/stdin test > > .headers on > .mode column > select * from test; > > EOF Some of those lines are commands to your Unix shell and others are commands for the sqlite3 program. You cannot mix a shell script and SQL commands like that. Try these three files: $ cat file.tsv 1 eenie 2 meenie 3 miny 4 mo $cat importfile.sql create table test (id integer primary key, value text); .separator "\t" .import file.tsv test .headers on .mode column select * from test; $cat importfile #!/usr/bin/env bash rm -f main.db sqlite3 main.db '.read importfile.sql' I have not tested this, but it should point you in the right direction. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users