Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 05-28-2013, 07:21 PM   #1
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
invoking sql in a shell script

Hi all,

I would like to invoke sql to update a table in KoboReader.sqlite on my Kobo.
But, if I am able to write the sql update, tested on a copy of the KoboReader.sqlite on my PC (Windows 8) with the SQLite Manager for firefox, I don't know the way to access this database in shell.

My purpose is to call the shell by a user command in the KoboTweaks plugin.

Can someone guide me to solve my problem ?
Thanks.
Mingyar is offline   Reply With Quote
Old 05-28-2013, 08:23 PM   #2
a3nm
Member
a3nm doesn't littera3nm doesn't littera3nm doesn't litter
 
Posts: 11
Karma: 204
Join Date: May 2013
Device: Kobo Glo
There is a command-line sqlite tool called sqlite3. First, you will need to install it to your Kobo. I haven't tested, but I would assume that you can install the one from Debian (following https://www.mobileread.com/forums/sho...12&postcount=2) along with all the packages it depends on.

Once installed, you can run sqlite3 on the KoboReader.sqlite database, passing the query(ies) that you want to run as standard input and getting the result as standard output. Here is an example:

Code:
echo 'select * from user;' | sqlite3 /mnt/onboard/.kobo/KoboReader.sqlite
I hope this helps.
a3nm is offline   Reply With Quote
Advert
Old 05-29-2013, 03:10 AM   #3
yoq
Developer
yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.yoq ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 206176
Join Date: Apr 2013
Location: Europe
Device: Kobo Glo
The japanese CFW includes a compiled sqlite3 and scripts as examples:
https://www.mobileread.com/forums/sho...d.php?t=213116
look in the KoboRoot.tgz in the .kobo folder in Kobo_CFW_Ver0.95.zip
yoq is offline   Reply With Quote
Old 05-29-2013, 06:46 AM   #4
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
Thanks fo your answers.

I thought that was only a syntax question, didn't think I would have to install anything.

Is there a language (C or else) in wich I can programm my sql update and call it in my shell, without installing anything ?
I suppose there's a solution, parts of the firmware acceed to this database, so all is here to do it. (maybe I'm wrong)
Mingyar is offline   Reply With Quote
Old 05-29-2013, 08:08 AM   #5
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
I think it's more simple to install the tool... see the link posted by yoq, you have only to copy that file.
Lucas Malor is offline   Reply With Quote
Advert
Old 05-29-2013, 09:05 AM   #6
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
Thanks Lucas and yoq.

From the KoboRoot.tgz got on the yoq's link, I removed everything in, except :
/bin/sqlite3
/usr/lib/libsqlite3.so.0
/usr/lib/libsqlite3.so.0.8.6

Do you confirm it's the only necessary files needed to invoke sql in shell ?
Mingyar is offline   Reply With Quote
Old 05-29-2013, 09:23 AM   #7
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
I don't know, I've not ever used it. Just try
Lucas Malor is offline   Reply With Quote
Old 05-29-2013, 04:53 PM   #8
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
After tests, I have to keep 4 other files :
/usr/lib/libncurses.so.5 2
/usr/lib/libncurses.so.5.7
/usr/lib/libreadline.so.6
/usr/lib/libreadline.so.6.1

I have another question :
Let's suppose my shell is /mnt/onboard/.kobo/MyShell.sh
How do I have to build my KoboRoot.tgz to make this shell automatically called after upgrade with the plugin ?
Mingyar is offline   Reply With Quote
Old 05-29-2013, 05:07 PM   #9
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
I have not understood well... with "shell" do you mean script? Do you want to automatically invoke a script at startup, and reinstall it easily after every firmware upgrade?

If so, to run the script at startup you have only to add it to the rcS file. About reinstalling the hack, take a look to the source code of the Night Mode hack: yoq had implemented a simple way to do it.

I suggest you to _not_ put under /mnt/onboard the script and any other file your hack will use, since they could corrupt your database (see Night Mode thread).

Last edited by Lucas Malor; 05-29-2013 at 05:11 PM.
Lucas Malor is offline   Reply With Quote
Old 05-29-2013, 05:13 PM   #10
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
Excuse me for my bad English, I'm French.

What I want to do, is to run my script one time, just after the plugin has been installed.
If the solution is to force startup, I've understand your explanation.
If there's a solution to make it run without restart the Kobo, I don't know how.

Last edited by Mingyar; 05-29-2013 at 05:21 PM.
Mingyar is offline   Reply With Quote
Old 05-29-2013, 05:22 PM   #11
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
But do you want to run the script only one time, or when you need it? If it's the second one, you can install the Tweaks hack and create an entry in kobotweaks.ini.

(My english is not better... trust me I'm using check spelling and wordreference a lot, and anyway I do a billion of edits. I think that one of these days I could cause a DDoS)
Lucas Malor is offline   Reply With Quote
Old 05-29-2013, 05:27 PM   #12
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
Only one time, the script remove himself in last instruction.
Only just after plugin has been installed.
Mingyar is offline   Reply With Quote
Old 05-29-2013, 05:37 PM   #13
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
Ooooook, you have to check the source code of the installer of yoq's Night Mode hack.

I'm curious... do you want to silently destroy your enemy's Kobo? :-p
Lucas Malor is offline   Reply With Quote
Old 05-29-2013, 05:41 PM   #14
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
If I make my plugin work, I'll explain his purpose
Mingyar is offline   Reply With Quote
Old 05-29-2013, 06:58 PM   #15
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
So, I looked at the nightmode plugin.
I see a file /root/autorun.sh
I made one for my plugin :
Code:
/mnt/onboard/.kobo/MyShell.sh
rm /root/autorun.sh
sync
reboot
But, my script don't run after plugin installation.
Mingyar is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pdf to txt shell script Mr.Castro0o PDF 0 03-27-2013 07:39 AM
Shell script to wait for user input from K3g keyboard jmseight Kindle Developer's Corner 33 04-01-2012 04:32 PM
Bash Script/SQL Query for ISBN in filename? zenrhino Calibre 1 09-26-2010 08:55 AM


All times are GMT -4. The time now is 10:04 PM.


MobileRead.com is a privately owned, operated and funded community.