farmir farmir - 1 year ago 120
Bash Question

run command line sqlite3 query and exit

We can use

option with
to run a query, but then
opens the database and waits in there for interactive input. How can we run a query on
from the command line and exit?


Answer Source

Just include the command in quotes after the database file argument.

For example, the following creates a table called abc:

sqlite3 test.db 'create table abc (col0 int)'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download