Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 06-29-2024, 12:15 AM   #1
shadowstone
Junior Member
shadowstone began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jun 2024
Device: Kobo
Fastest way to query calibre database

Hello there!

I'm a new user of calibre who's getting into it to organise my collection of books (mainly pdfs) and I was wondering what was the best way to query the database? I've been wanting to make a small shell script that gets the titles of all books in the calilbre database (for a drun like selection menu before opening their files in zathura) and wondered what was the fastest way to do it? I'm currently getting them all with `calibredb list -f title` sometimes with an extra `--with-library` command while calibre itself is running, but I was wondering if anyone else had some faster suggestions? Currently it's taking 0.3-0.4 second per query and gives noticeable lag when trying to load up the drun replacement I have (tofi).

Thank you all for your help!
shadowstone
shadowstone is offline   Reply With Quote
Old 06-29-2024, 12:45 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,657
Karma: 24966646
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibredb is fairly slow to startup mostly because of python interpreter startup lag. In addition it has to open and parse metadata.db on every invocation. You can get an idea of the breakup of times for these two tasks by contrasting the time taken for

calibredb --help
vs
calibredb list --limit=1

The latter of the two can be reduced by having calibredb connect to a running calibre-server instance. Or you can just use one of the JSON endpoint of the calibre server directly, which should be basically instantaneous. This does require keeping calibre running in the background. If you dont want to do that, you can just query metadata.db yourself using some sqlite tool. Getting a list of titles from it is pretty trivial, it involves simply reading the title column from the books table.
kovidgoyal is offline   Reply With Quote
Advert
Old 06-29-2024, 04:58 AM   #3
shadowstone
Junior Member
shadowstone began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jun 2024
Device: Kobo
Quote:
Originally Posted by kovidgoyal View Post
calibredb is fairly slow to startup mostly because of python interpreter startup lag. In addition it has to open and parse metadata.db on every invocation. You can get an idea of the breakup of times for these two tasks by contrasting the time taken for

calibredb --help
vs
calibredb list --limit=1

The latter of the two can be reduced by having calibredb connect to a running calibre-server instance. Or you can just use one of the JSON endpoint of the calibre server directly, which should be basically instantaneous. This does require keeping calibre running in the background. If you dont want to do that, you can just query metadata.db yourself using some sqlite tool. Getting a list of titles from it is pretty trivial, it involves simply reading the title column from the books table.
Thank you so much! Using sqlite really sped it up.
shadowstone is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre Companion - metadata only query Josieb1 Calibre Companion 9 11-12-2015 09:47 AM
Calibre Database cp Kindle Database mitch13 Library Management 1 05-22-2011 08:33 PM
PC Memory use of Calibre query JustinD Calibre 1 03-28-2011 08:29 PM
Query regarding Calibre setup culpr1t Calibre 3 01-11-2011 04:02 PM
Query about Calibre 0.7.9 and request mitch13 Calibre 5 07-22-2010 11:19 PM


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


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