View Single Post
Old 12-09-2014, 04:43 PM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,495
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Howlingwolf View Post
I was testing an idea for programmatically adding books to a Calibre library and encountered a problem with custom columns.

I'm using mi.set('#subtitle', Subtitle) - following this with mi.get('#subtitle') shows the data is being set correctly - but this is not being 'carried over' into the library metadata.

This is a 'standalone' script run using calibre-debug, not a plugin.

Is this related to the metadata plugin issue I've seen mentioned elsewhere or something I'm doing wrong?
You are doing something wrong.

mi.set changes the value in the metadata instance (in memory). It does not write that value to the database. To write to the database you should use new_api.set_field() (db.cache.py) if you are writing only a few fields or set_metadata() (db.legacy.py or cache.py) if you are changing many fields. Both assume that you have access to a database instance.

The thread https://www.mobileread.com/forums/sho...d.php?t=241680 has an example of using set_field.
chaley is offline   Reply With Quote