how can i create a sqlite3 database?

251 views
Skip to first unread message

David Macias Hurtado

unread,
Oct 14, 2013, 4:18:57 AM10/14/13
to tas...@googlegroups.com
The command "sqlite3 mydatabase.db" doesn't work.

ICWiener_

unread,
Oct 14, 2013, 5:22:06 AM10/14/13
to tas...@googlegroups.com
Hello,
I think you should use the complete path :
Action : run shell
sqlite3 /sdcard/mydatabase.db;
(don't forget the ";" at the end of each line)

David Macias Hurtado

unread,
Oct 14, 2013, 5:45:33 AM10/14/13
to tas...@googlegroups.com
Yes, im running this command with root:

sqlite3 /sdcard/mydb.db;

But it doesn't work...

David Macias Hurtado

unread,
Oct 14, 2013, 7:04:29 PM10/14/13
to tas...@googlegroups.com
Nobody knows it?

Jenny Hawkins

unread,
Oct 14, 2013, 7:42:09 PM10/14/13
to tas...@googlegroups.com
sqlite3 /sdcard/mydata/mydatabase.db "CREATE TABLE IF NOT EXISTS mytable (fieldA, fieldB, fieldC)"

Keep doing that for every table you want. The folder has to already exist, or you can use the root of the sdcard.

David Macias Hurtado

unread,
Oct 15, 2013, 4:42:40 AM10/15/13
to tas...@googlegroups.com
Thanks for answers, but these commands do not work. i've tried it with:

sqlite3 /sdcard/folder/mydatabase.db "CREATE TABLE IF NOT EXISTS mytable (fieldA char (6) , fieldB char (10) )";
("folder" already exist)

sqlite3 /sdcard/folder/mydatabase.db "CREATE TABLE IF NOT EXISTS mytable (fieldA, fieldB, fieldC)";

sqlite3 /sdcard/folder/mydatabase.db "CREATE TABLE mytable (fieldA, fieldB, fieldC)";

sqlite3 /sdcard/folder/mydatabase.db;

Nothing...even with root access.

Is this a bug?

Badhri Narayanan

unread,
Oct 15, 2013, 5:02:49 AM10/15/13
to tas...@googlegroups.com
Does it execute successfully on Terminal? You might try installing terminal emulator and see, if this is properly working in it. Or try ADB shell from your laptop and see if it is successful.

David Macias Hurtado

unread,
Oct 15, 2013, 5:08:55 AM10/15/13
to tas...@googlegroups.com
I'm going to try...

David Macias Hurtado

unread,
Oct 15, 2013, 5:20:40 AM10/15/13
to tas...@googlegroups.com
Well,i've just tested this command on Terminal:

sqlite3 /sdcard/folder/mydatabase.db "CREATE TABLE IF NOT EXISTS mytable (fieldA char (6) , fieldB char (10) )";

sqlite3 /sdcard/folder/mydatabase.db "CREATE TABLE IF NOT EXISTS mytable (fieldA, fieldB, fieldC)";

Both works correctly...

Then, is this a bug?

David Macias Hurtado

unread,
Oct 15, 2013, 10:11:43 AM10/15/13
to tas...@googlegroups.com
Up

Badhri Narayanan

unread,
Oct 15, 2013, 10:32:20 AM10/15/13
to tas...@googlegroups.com
Hmm.. Few more steps :)  I hope you tested it on the Terminal Emulator app in your phone and found it working. If so, then please try the following things

-> Insert atleast a row in the Table you created above(in Terminal Emulator)

-> Select a column's data from that table you created from Tasker Run Shell action. So something like:
Run Shell(With Root) and store the output in a variable -> sqlite3 /sdcard/mydata/mydatabase.db "select fieldA from mytable";
and see whether this is returning anything, by flashing the variable.

-> There is a plugin called Secure Settings, which also supports the Run Shell action with Root(i believe it is called Run Command), try that Secure Settings action with the query you want. Remember to give a value for Error Variable and Output Variable and see, what those variables contain, by flashing. I'm particularly concerned about the Error Variable's value.

David Macias Hurtado

unread,
Oct 17, 2013, 5:53:20 AM10/17/13
to tas...@googlegroups.com
I've just found the problem...tasker can read data from /sdcard/.../ but it cannot write in /sdcard/.../. I don't know why, but the correct path for this is /storage/emulated/0/.../, this is the same path (sdcard).

I think this path works fine...

Reply all
Reply to author
Forward
0 new messages