Daniele Nicolucci (Jollino) wrote:

Ok, I guess I'll have to live without having an auto-increment field or find a way to fill it in the csv file with explicit values... my C skills are almost null so I don't even attempt to do that. Or I could write a simple script to generate INSERTs from csv files and keep the field. I'll play with it.


Daniele,

You should be able to do what you want in few steps.

1) Remove the null column from your CSV file.

   f,35,c,d,a,a
   f,48,a,b,c,d
   m,22,b,c,d,a

2) Create a temp table with the same columns as your table except for the id column, leave that one off.

   CREATE TEMP TABLE temp(sesso, eta, dom1, dom2, dom3, dom4);

3) Use .import file temp_table to import all the data into the temp table. This will work with the SQLite code since it doesn't need to recognize null values.

   .import valori.csv temp

4) Now use the following insert command to copy the data into your table. This insert doesn't supply a value for id so SQLite will provide a unique id value automatically.

INSERT INTO quest (sesso, eta, dom1, dom2, dom3, dom4) select * from temp;

5) Drop the temp table


I hope this helps.

Dennsic Cote

Reply via email to