05-19-2024, 04:59 PM | #1 |
Connoisseur
Posts: 64
Karma: 10
Join Date: Jan 2010
Device: Onyx Boox Poke 3
|
What would be the best/correct way do query for
I have a custom read/unread column.
I'm aware of calibredb, but not very familiar with it. What I tried to do was Code:
calibredb --library-path=/path/to/library list --fields "series,series_index" --search 'series:True series_index:1.0 #readstatus:"=Read"' --sort-by 'series' 1. The sort is reverse alphabetical (I want alphabetical) 2. The sort is done where "insignificant" words like "A" or "The" are disregarded (I want them included) 3. It still prints the ID, despite me not including it in --fields (I don't want the ID shown). I was able to handle this with a mixture of various Linux text processing tools like cut, sed, and sort, but ideally I wouldn't have to do this somehow? Once I get that down, I want to additionally select the MAX series index for each series, but I have no clue how I'd do that. Last edited by Trel; 05-19-2024 at 05:03 PM. |
05-19-2024, 09:36 PM | #2 |
Zealot
Posts: 106
Karma: 1133068
Join Date: Sep 2007
Device: ipaq
|
It won't get rid of the id, but try:
list --fields series,series_index --search "series:true and series_index:1.0 and #readstatus:Read" --sort-by series --ascending |
Advert | |
|
05-20-2024, 05:05 PM | #3 | |
Connoisseur
Posts: 64
Karma: 10
Join Date: Jan 2010
Device: Onyx Boox Poke 3
|
Quote:
That addresses the reverse sort, but it also breaks filtering on readstatus because "read" matches "read" and "unread", it's gotta be "=Read". It unfortunately doesn't help the issue with 'a' and 'the' not getting sorted alphabetically either. |
|
05-20-2024, 11:29 PM | #4 |
creator of calibre
Posts: 44,557
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you want to sort including leading articles create a custom column in the library that uses a template to generate the value of series. It will sort using the value as a simple string.
|
05-21-2024, 01:28 PM | #5 | |
Zealot
Posts: 106
Karma: 1133068
Join Date: Sep 2007
Device: ipaq
|
Quote:
Maybe a built-in Series Sort field similar to Author Sort and Title Sort would make sense and then allowing the user to sort by either the literal field or the sort field. Is there any way to suppress the output of the id field? |
|
Advert | |
|
05-21-2024, 01:52 PM | #6 | |
creator of calibre
Posts: 44,557
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
And no you cannot suppress ids without them you can get duplicate rows. If you want full control use --for-machine which will output json and then postp process however you like using a tool such as jq or similar. |
|
06-11-2024, 08:23 PM | #7 |
Connoisseur
Posts: 64
Karma: 10
Join Date: Jan 2010
Device: Onyx Boox Poke 3
|
I know it's considered poor form to hit the database directly, but I managed to get this to so far grab the latest book in all series, I'm going to incorporate my custom Read/Unread column soon. Is there any real harm/risk in opening the DB in read only mode and running selects?
Code:
SELECT series_id ,book_id ,MAX(series_index) AS series_index ,series ,title FROM ( SELECT s.sort AS series ,b.id AS book_id ,b.title AS title ,s.id AS series_id ,b.series_index AS series_index FROM books_series_link AS bs LEFT JOIN books AS b ON bs.book = b.id LEFT JOIN series AS s ON bs.series = s.id ) GROUP BY series_id ORDER BY series ASC; |
06-11-2024, 08:55 PM | #8 |
Grand Sorcerer
Posts: 12,032
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
FWIW: a search for selecting the highest Series_Index ?
|
06-12-2024, 12:57 AM | #9 |
Connoisseur
Posts: 64
Karma: 10
Join Date: Jan 2010
Device: Onyx Boox Poke 3
|
I'm trying to do this to be able to export things like CSV and similar.
My final query which looks to be working is Code:
SELECT series_id ,book_id ,MAX(series_index) AS series_index ,series ,title ,read_status FROM ( SELECT s.sort AS series ,b.id AS book_id ,b.title AS title ,s.id AS series_id ,b.series_index AS series_index ,cc2.value AS read_status FROM books_series_link AS bs LEFT JOIN books AS b ON bs.book = b.id LEFT JOIN series AS s ON bs.series = s.id LEFT join books_custom_column_2_link AS bcc2 ON b.id = bcc2.book LEFT join custom_column_2 AS cc2 ON bcc2.value = cc2.id ) GROUP BY series_id ORDER BY series ASC; EDIT: this is all precursor for me searching out and finding if I've completed a completed series and adding custom metadata to that effect, but also something I frequently try to look up Last edited by Trel; 06-12-2024 at 01:02 AM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Query re editor | johngross | Editor | 0 | 10-07-2019 05:46 PM |
meaning and how to correct | ralphiedee | Sigil | 4 | 10-17-2012 04:48 PM |
Metadata query | iain robinson | ePub | 4 | 08-08-2012 01:07 PM |
Hello and query | MPDuke | Introduce Yourself | 8 | 12-13-2011 11:27 AM |
Query - Kindle DX US | ukhant | Kindle Developer's Corner | 2 | 07-20-2010 04:23 AM |