Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 09-02-2016, 03:59 PM   #1
praimon
Member
praimon began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Oct 2013
Device: none
Directly manage library from sqlite3?

Hello,
Before I do something silly, I have a question:
If I directly manipulate the metadata.db file with sqlite3 (perhaps via a non-python program), will calibre recognize and accept the changes without a problem?

Thank you.
praimon is offline   Reply With Quote
Old 09-02-2016, 04:08 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,950
Karma: 55705602
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Danger Will Robinson

The DB contains everything about YOUR book file.
The program takes care of the needed details. You miss something and

Consider using the CLI tools instead
theducks is offline   Reply With Quote
Advert
Old 09-02-2016, 04:29 PM   #3
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
If you directly manipulate the db, then it is up to you to make sure you don't break anything... I strongly encourage you to use the `calibredb` CLI backend, or if you need a lot of flexibility, using the calibre apis via `calibre-debug` python scripts. e.g.

Code:
def init_cache(library_path=None):
    if not library_path:
        from calibre.utils.config import prefs
        library_path=prefs['library_path']
    from calibre.db.backend import DB
    from calibre.db.cache import Cache
    backend = DB(library_path)
    cache = Cache(backend)
    cache.init()
    return cache
This grants you access to the functions described in API Documentation for the database interface
eschwartz is offline   Reply With Quote
Old 09-02-2016, 06:42 PM   #4
praimon
Member
praimon began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Oct 2013
Device: none
Thanks for the code example, it was instructive comparing it to the 'official' technique:

Code:
from calibre.library import db
db = db('Path to calibre library folder').new_api
I'm learning python as I read calibre's source, so I'm having some fun. On the other hand, I'm well versed in using sqlite from clojure, so that might actually be the safer option.
praimon is offline   Reply With Quote
Old 09-02-2016, 07:05 PM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
The code I posted is a snippet I got from chaley.

The code in the manual uses a compatibility layer providing the old and new apis, chaley's snippet directly accesses the new database classes... other than that it is basically the same I guess.
Though I have expanded the snippet to default to your currently-configured Calibre Library via prefs.

...

If you are going to use sqlite, you will have to write the functions and validation code to make sure you are modifying the database in accordance with calibre's scheme, but other than that you *should* be fine.
Previous experience with sqlite/clojure may very well trump using existing apis in that case.

Best of luck.
eschwartz is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library skips publisher, goes directly to author kennyc Writers' Corner 5 08-05-2013 06:26 AM
Touch How to manage large library on NST? blemons Barnes & Noble NOOK 3 12-02-2012 08:05 AM
Kobo eReader Manage Library jsandiego Kobo Reader 1 09-12-2011 01:43 PM
Help please manage library for kindle ragnorak Library Management 2 06-15-2011 07:45 PM
manage stanza library from desktop? sovre Apple Devices 0 02-03-2011 05:20 PM


All times are GMT -4. The time now is 04:24 AM.


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