View Single Post
Old 06-04-2025, 06:05 AM   #350
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 Majutsushi View Post
That's an interesting idea, although I'm not sure how it could be implemented without either being too specific or effectively reinventing plugboards. Or do you mean actually allowing you to run an arbitrary SQL query? That would certainly be possible but also very dangerous like Terisa said. It would also have to be run in a similar manual way to what Terisa described since I don't think there's a way to hook into an eject event.
Quote:
Originally Posted by Majutsushi View Post
I just had an idea: since you can write custom modules for the ActionChains plugin in Python, it should be possible to write a module that calls into the KoboUtilities plugin so that it gives you a database connection, and then the module can use that connection to run any query it wants. Currently the relevant method would be "calibre_plugins.koboutilities.action.KoboUtilitie sAction.device_database_connection()". You need the running instance of that action though, and I'm not sure how to get access to that from a module. That's a question for people who are more familiar with that plugin.
It seems to me that the "right" way to do this is to provide a field in KU to set the text form of the series index. That field would be a combination checkbox and template, just as is used in the kobo driver for "collections columns", "collections template", etc. The user would check the box and supply a template that returns the desired string for the series index, which KU would write to the device database. You would need an open database connection to pass to the template processor. Yes, this is specific to series, but that makes it understandable and safe.

I strongly advise you not to pass around database connections. There are all sorts of ways where these can lead to disaster, for example when threading. It would also permit a user to rather easily trash the database.
chaley is offline   Reply With Quote