Reputation: 2279
I need to get data from a PostgreSQL table into an SQLite table. I am exporting the data from PostgreSQL into a CSV file, and then trying to import it into SQLite from a command-line prompt. First I tried this:
c:> /sqlite3/sqlite3 sample.trd ".import source_file.csv trend_data"
For every line in the file, I got an error message saying SQLite expected three values and there was only one. Not really surprising because I never told SQLite that the file was a CSV file. So then I tried this:
c:> /sqlite3/sqlite3 sample.trd ".mode csv .import source_file.csv trend_data"
I got no errors, but I also got no data.
Upvotes: 1
Views: 1929
Reputation: 180020
Each dot command must be alone in a single line.
You could pipe multiple commands into sqlite3
, but in this case, it would be easier to set CSV mode with a parameter:
sqlite3 -csv sample.trd ".import source_file.csv trend_data"
Upvotes: 6