Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-13-2015, 05:57 AM   #1
mirikbb
Member
mirikbb began at the beginning.
 
Posts: 14
Karma: 10
Join Date: Jan 2012
Device: Kindle
Question how to get list of custom column

Hello,

please, is there any attribute of gui.current_db object to enumerate and work with custom columns?

Or what is proper way to use custom columns? Thanx a lot.
mirikbb is offline   Reply With Quote
Old 04-13-2015, 07:09 AM   #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,374
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
It is very hard to answer you without more information about what you want to do with them.

To directly answer the question, use gui.db.custom_field_keys(include_composites=True) to get a list of keys (lookup names) of the custom columns in the current library.

There are many methods in gui.db.new_api (db/cache.py) to manipulate fields. Custom columns are just another example of fields.
chaley is offline   Reply With Quote
Advert
Old 04-14-2015, 01:28 AM   #3
mirikbb
Member
mirikbb began at the beginning.
 
Posts: 14
Karma: 10
Join Date: Jan 2012
Device: Kindle
Quote:
Originally Posted by chaley View Post
It is very hard to answer you without more information about what you want to do with them.

To directly answer the question, use gui.db.custom_field_keys(include_composites=True) to get a list of keys (lookup names) of the custom columns in the current library.

There are many methods in gui.db.new_api (db/cache.py) to manipulate fields. Custom columns are just another example of fields.
I am newbie in python programming and trying to learn it a bit. I want to populate drop down menu with custom column list. Selected custom column will be proceeded after.
I will place maybe more general question, is there updated list/documentation of all methods usable in calibre plugin programming or I have to go through the cache.py as suggested?
mirikbb is offline   Reply With Quote
Old 04-14-2015, 01:30 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,258
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
http://manual.calibre-ebook.com/db_api.html#db-api
kovidgoyal is offline   Reply With Quote
Old 04-14-2015, 02:01 AM   #5
mirikbb
Member
mirikbb began at the beginning.
 
Posts: 14
Karma: 10
Join Date: Jan 2012
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
Thanx for link, of course I found and checked it at the very beginning. Maybe I am misising here something, maybe complete python basics. I couldn't find in the API doc anything about gui.db.custom_field_keys, otherwise I wouldn't place the question here.
mirikbb is offline   Reply With Quote
Advert
Old 04-14-2015, 02:44 AM   #6
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,374
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You should look at library/field_metadata.py. It explains what field (column) datatypes are available and has lots of methods for manipulating this information. You can get a field_metadata dict using something like fm = gui.db.field_metadata
chaley is offline   Reply With Quote
Old 04-14-2015, 06:57 AM   #7
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
@mirikbb: You can read the manual, look at calibre source, or do what I do: find a plugin that does what I need and "borrow" some code. I recommend just about any of kiwidude's plugins. And as you are after custom columns, then Count Pages is probably the one.
davidfor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
View list of custom column settings? BookJunkieLI Calibre 8 07-25-2014 09:36 AM
Custom Column Colors for "Text but with a fixed list of permitted values" Skeeve Calibre 5 04-03-2014 01:44 PM
Custom column returns value based on value of another custom column? calvin-c Calibre 3 09-14-2013 02:24 PM
Custom yes/no column built from long text column Philantrop Library Management 7 03-23-2013 07:44 PM
Custom Column with list of permitted values Eugenie Library Management 1 01-10-2012 03:57 AM


All times are GMT -4. The time now is 12:26 AM.


MobileRead.com is a privately owned, operated and funded community.