Link to home
Start Free TrialLog in
Avatar of vishnu kalakota
vishnu kalakota

asked on

how to insert and display data in sqlite3 using bash?

i have three variables holding information
var1=CSI6221 Project 1    2015 Semester 1
var2=WED
var3=12:30 - 13:30
var4=ML 03.102 Tutorial Room
sqlite3 test.db "create table  timetable_info (ID INTEGER
       PRIMARY KEY,unitinfo TEXT,day TEXT,time TEXT,location TEXT);" ### created a table like this
sqlite3 test.db  "insert into timetable_info (unitinfo,day,time,room) values ('$var1', '$var2', '$var3' '$var4');" inserted values this way.
sqlite3 test.db  "select * from timetable_info;"  ### i tried to display data..
i ended up with the message  Error:::: near "'ML 03.102 Tutorial Room'": syntax error


can any help what this means?


thank you
Avatar of johnsone
johnsone
Flag of United States of America image

Because you have spaces in your variable values.  It should be this:

var1="CSI6221 Project 1    2015 Semester 1"
var2="WED"
var3="12:30 - 13:30"
var4="ML 03.102 Tutorial Room"
ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vishnu kalakota
vishnu kalakota

ASKER

Stuck with the silly mistake since couple of days..
thanks very much...