Reputation: 971
I try to emulate this tutorial
http://www.sqlitetutorial.net/sqlite-import-csv/
(basically, create a new DB and create a new table in that DB from a CSV file)
using a shell script but am stuck on the first few commands.
I think I can create a new db in a non-interactive script like this
sqlite3 test.db <<EOF
but how do I then set the mode to csv? I am having problem with the syntax.
I have found a few examples here on SE for Python and PHP but they seem to use built-in functions in those languages rather than the sqlite prompt.
Upvotes: 0
Views: 819
Reputation: 91
#!/bin/bash
sqlite3 <<EOF
.mode csv
.import file.csv tbl
.save file.db
EOF
Upvotes: 1