First of all, this is a strange demand ... But I met him. I refer to the method after the text link, do their own.
The table is manually built, the database name is new.db:
CREATE TABLE Test (SN varchar,name varchar);
Well, it's starting to work under the shell. The first is to assemble our query:
query="insert into test values (\" 1\ ", \" luo\ "); "
Then, specify the database:
sqlitedb="sqlite3 new.db"
Next, send the prepared query to the database:
$sqlitedb <<eof$query.quiteof
In fact, this just opens the database and then sends a few lines of text between the two EOF to the standard input of sqlite3. The. Quit here seems to be a must, keep it first.
Take the data similar, I use the following sentence to try:
result=$ ($sqlitedb <<eof$query.quiteof)
After executing this sentence, print result:
Echo $result 1 2|zhou
Obviously, this is possible.
http://blog.csdn.net/wangbole/article/details/8062529
Bash Operation Sqlite3