Thank you very much Simon. 

That worked very slick. 



Say, is there a way to put all of the SQLite3 commands  I used into a script 
and have SQLite3 execute them in the script sequentially? 



-Chris 


----- Original Message ----- 
From: "Simon Davies" <simon.james.dav...@googlemail.com> 
To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> 
Sent: Thursday, July 8, 2010 4:48:20 PM 
Subject: Re: [sqlite] importing data from file with 3 colums to table with 
4        columns 

On 9 July 2010 00:07,  <c...@comcast.net> wrote: 
> 
> 
> Hello, 
> 
> I have a db tbl with the following schema: 
> 
> 
> 
> _ID integer primary key autoincrement 
> 
> name varchar(40) 
> 
> category varchar(40) 
> 
> recommendation varchar(40) 
> 
> 
> 
> I have a data file I want to import which contains 3 columns worth of data. 
> 
> It looks like this: 
> 
> 
> 
> Barracuda|seafood|No 
> Catfish|seafood|No 
> Caviar|seafood|No 
> Conch|seafood|No 
> Herring(pickled)|seafood|No 
> Lox(smoked salmon)|seafood|No 
> Octopus|seafood|No 
> 
> 
> 
> When I try and import it I get the following error: 
> 
> "line 1: expected 4 columns of data but found 3" 
> 
> 
> 
> Since I obviously don't want to explicitly load data into the _ID column, how 
> do I tell it to put the data from the import file into the 3 remaining 
> columns? 
> 

Create a table (tmp) with three cols to receive the data from your 
file, then use 
INSERT INTO tbl( name, category, recommendation ) SELECT * from tmp; 

> 
> 
> Thank you in advance. 
> 
> -Chris 
> 

Regards, 
Simon 
_______________________________________________ 
sqlite-users mailing list 
sqlite-users@sqlite.org 
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to