View Single Post
Old 08-17-2020, 12:03 PM   #12
Difflugia
Testate Amoeba
Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.Difflugia ought to be getting tired of karma fortunes by now.
 
Difflugia's Avatar
 
Posts: 3,049
Karma: 27300000
Join Date: Sep 2012
Device: Many Android devices, Kindle 2, Toshiba e755 PocketPC
Quote:
Originally Posted by Patrick Derwael View Post
Ideally, I would like something like
tag1 - book1
tag1 - book2
...
tag2 - book1
tag2 - book2
...

Any clue on how to do this?
The tag information is stored in the SQLite database file metadata.db. If you're comfortable using the command line and willing to access the database file directly, you can get exactly what you want.

First, here's the query in case you don't need the rest of the explanation:
Code:
SELECT a.name, b.author_sort, b.title
FROM tags a, books b, books_tags_link c
WHERE a.id = c.tag AND b.id = c.book
ORDER BY a.name, b.author_sort, b.title;
The command line tool for can be downloaded from the SQLite website here. Under Precompiled Binaries for Windows, you want "sqlite-tools-win32-x86-3330000.zip". The zip file contains three executables, one of which is named "sqlite3.exe".

My suggestion is that you create a separate working directory for this. First, make a copy of the "metadata.db" file from your Calibre directory in the new directory (the tool will let you make irreversible changes to your Calibre database, so work from a copy). Then copy the "sqlite3.exe" file into the same directory. Finally, create a text file named "tags.sql" in the directory and paste the above query into it.

Open a Windows command line and cd to the directory you created. Type "sqlite3 metadata.db" and you should see the following:
Code:
SQLite version 3.33.0 2020-08-14 13:23:32
Enter ".help" for usage hints.
sqlite>
The command ".read some_file" will execute SQLite commands from some_file. The command ".output some_other_file" will redirect all output to the file instead of the screen. Type or paste the following commands at the sqlite> prompt to create a "tags_output.csv" file that you can import into Excel.
Code:
.output tags_output.csv
.read tags.sql
.quit
Unfortunately, the field separator isn't a comma, but a vertical bar. I guess that means it's not actually a CSV file, but if you're comfortable importing files into Excel, I assume you can find the spot in the dialog that lets you pick a different delimiter.
Difflugia is offline   Reply With Quote