09-02-2016, 04:59 PM | #1 |
Member
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. |
09-02-2016, 05:08 PM | #2 |
Well trained by Cats
Posts: 30,443
Karma: 58055868
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 |
Advert | |
|
09-02-2016, 05:29 PM | #3 |
Ex-Helpdesk Junkie
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 |
09-02-2016, 07:42 PM | #4 |
Member
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 |
09-02-2016, 08:05 PM | #5 |
Ex-Helpdesk Junkie
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. |
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library skips publisher, goes directly to author | kennyc | Writers' Corner | 5 | 08-05-2013 07:26 AM |
Touch How to manage large library on NST? | blemons | Barnes & Noble NOOK | 3 | 12-02-2012 09:05 AM |
Kobo eReader Manage Library | jsandiego | Kobo Reader | 1 | 09-12-2011 02:43 PM |
Help please manage library for kindle | ragnorak | Library Management | 2 | 06-15-2011 08:45 PM |
manage stanza library from desktop? | sovre | Apple Devices | 0 | 02-03-2011 06:20 PM |