|
|
#1 |
|
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Jan 2025
Device: None
|
Update custom column value
I have this code:
Code:
book_ids = self.gui.library_view.get_selected_ids()
db = self.gui.current_db.new_api
for book_id in book_ids:
book = db.format_abspath(book_id, "txt") # This method breaks thread-safe promise of API, fix later
metadata = db.get_metadata(book_id)
How do I change the value of a column? |
|
|
|
|
|
#2 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Use
Code:
set_field(self, name, book_id_to_val_map, allow_case_change=True, do_path_update=True)
'''
Set the values of the field specified by ``name``. Returns the set of all book ids that were affected by the change.
:param book_id_to_val_map: Mapping of book_ids to values that should be applied.
:param allow_case_change: If True, the case of many-one or many-many fields will be changed.
For example, if a book has the tag ``tag1`` and you set the tag for another book to ``Tag1``
then the both books will have the tag ``Tag1`` if allow_case_change is True, otherwise they will
both have the tag ``tag1``.
:param do_path_update: Used internally, you should never change it.
'''
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Jan 2025
Device: None
|
I got it to work, thanks!
Turns out the val_map is just a dictionary with book ids as key |
|
|
|
|
|
#4 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
BTW: add_custom_book_data() does not update custom columns. Instead it updates a look-aside table that plugins can use to store information about books.
|
|
|
|
|
|
#5 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,687
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
|
|
|
|
| Advert | |
|
|
|
|
#6 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
If you want to update custom columns then use db.new_api.set_field(). Last edited by chaley; 05-10-2025 at 09:15 AM. Reason: spelling |
|
|
|
|
|
|
#7 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,687
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
|
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using RE to extract pattern from custom column into another custom column | activedirectory | Library Management | 1 | 12-15-2019 09:07 PM |
| Adding custom column with any lookup-name gives me empty column as a result? | Ahu Lee | Library Management | 16 | 06-09-2019 01:14 PM |
| Move selected data from series column to a new custom column | fvdham | Library Management | 3 | 06-02-2017 04:49 PM |
| Custom column returns value based on value of another custom column? | calvin-c | Calibre | 3 | 09-14-2013 03:24 PM |
| Update custom column's content? | Pepin33 | Development | 1 | 08-18-2012 03:16 PM |