Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create a shell script to run sqlite commands from php in ubuntu

i want to create a new db of sqlite using A SHELL SCRIPT on an ubuntu10.10 OS....Any ideas??

I tried 'create.sh' file with following code...

#!/bin/bash
sqlite ex3.db
create table t1(f1 integer primary key,f2 text)

than run a ./create.sh from termminal but it leads me to sqlite> prompt...I dont see created DB ex3 anywhere..

Please help ...

like image 938
Roopa Avatar asked Apr 21 '11 07:04

Roopa


1 Answers

One more way to accomplish this can be using SQL_ENTRY_TAG_N

#!/bin/bash
sqlite3 mydatabase <<SQL_ENTRY_TAG_1
SELECT * FROM sqlite_master;
SQL_ENTRY_TAG_1

see snippet for details

like image 162
Kostiantyn Sokolinskyi Avatar answered Sep 26 '22 14:09

Kostiantyn Sokolinskyi