I have created a database - tasks.db - with SQLite. This database has one table - todo - with the following fields : id (pk), date (NOW with trigger), project, duedate, status, description
To enter a new row in SQLite from the command line, I have to write :
sqlite3 tasks.db "insert into todo (project,duedate,status,description) values (2010-11_18,'Home','Urgent','Call the plumber');"
which is a rather long and error-prone process. So I decided to "automate" it with a shell script (bsq) which runs as follows :
#!/bin/sh
echo "What project ?"
read Proj
echo "For when ?"
read Due
echo "What status ?"
read Stat
echo "What to do ?"
read Descr
echo sqlite3 tasks.db "insert into todo (project,duedate,status,description) values ('$Proj',$Due,'$Stat','$Descr');"
… and nothing happens when I run : sh bsq
. The sequence appears then brings me back to the prompt.
Where did I go wrong or what did I omit (ENTER ? but how do I do that ?)?
Thanks for your help.
Start the sqlite3 program by typing "sqlite3" at the command prompt, optionally followed by the name the file that holds the SQLite database (or ZIP archive). If the named file does not exist, a new database file with the given name will be created automatically.
RazorSQL can create a new SQLite database by going to the Connections -> Add Connection Profile menu option, selecting SQLite as the database type, and then on the next screen, entering the location for the new SQLite database file, etc. You can also connect to existing SQLite databases using RazorSQL.
SQLite CREATE Database In this SQLite tutorial, here is how you can create a new database: Open the Windows Command Line tool (cmd.exe) from the start, type “cmd” and open it. From the Installation and packages tutorial, you should now have created an SQLite folder in the “C” directory and copied the sqlite3.exe on it.
#!/bin/sh
echo "What project ?"
read Proj
echo "For when ?"
read Due
echo "What status ?"
read Stat
echo "What to do ?"
read Descr
echo "im gonna run" sqlite3 tasks.db "insert into todo \
(project,duedate,status,description) \
values (\"$Proj\",$Due,\"$Stat\",\"$Descr\");"
sqlite3 tasks.db "insert into todo (project,duedate,status,description) \
values (\"$Proj\",$Due,\"$Stat\",\"$Descr\");"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With