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
vishnu kalakotaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

johnsoneSenior Oracle DBACommented:
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"
0
Gerwin Jansen, EE MVETopic Advisor Commented:
You missed a comma in your insert statement and and you have the wrong column name for column #4.

Change your insert statement to this:
[gerwin@localhost tmp]$ sqlite3 test.db  "insert into timetable_info (unitinfo,day,time,location) values ('$var1', '$var2', '$var3','$var4');"

Open in new window


and test/display:
[gerwin@localhost tmp]$ sqlite3 test.db  "select * from timetable_info;"
1|CSI6221 Project 1    2015 Semester 1|WED|12:30 - 13:30|ML 03.102 Tutorial Room
[gerwin@localhost tmp]$ 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vishnu kalakotaAuthor Commented:
Stuck with the silly mistake since couple of days..
thanks very much...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.