Somebody, please help me, because my head going to explode.
I’m trying to import data in sqlite3. I have promos.sql and promos.csv files. I’ve tried to run this in the sqlite shell:
.read promos.sql
Or do this at a unix prompt:
sqlite3 development.sqlite3<promos.sqlite3
and each time I get error
Error: near line 1: near ",": syntax error Error: near line 18: near ",": syntax error e.t.c.
In file are following rows:
INSERT INTO promos (name, promo_type, category, phone, email, message, created_at) VALUES
('John', 1, 3, '+111 11 111 111 11', 'some@email.com', 'Some message', '2009-09-24 12:17:17'),etc
so, it complains on error in each line where goes columns enumeration.
If I try
.import promos.csv promos
it says:
Error: promos.csv line 1: expected 9 columns of data but found 1
but in file are 9 columns as expected:
"13","John","1","3","+111 11 111 111 11","some@email.com","Some message","2009-09-24 15:17:17", "2009-09-24 15:17:17"
Why is it not working?
For the sql problem: do you have commas at the end of your INSERT statments instead of semicolons like you should have? Please post several lines of your sql file that you’re trying to run, and also post the CREATE TABLE statement for
promos.For the csv problem: sqlite uses | as the default separator, so you’ll have to set it to use comma. Furthermore, sqlite import doesn’t recognise quoted columns so if you’ll have commas in your data you’re best using a different method to import the data. See this article for details.