Add functions to get the full database names currently in use via json-rpc and python api#27203
Add functions to get the full database names currently in use via json-rpc and python api#27203bacon-cheeseburger wants to merge 3 commits intoxbmc:masterfrom
Conversation
f6900fd to
2f058d3
Compare
2f058d3 to
7d324d7
Compare
ksooo
left a comment
There was a problem hiding this comment.
Good to go in, from my perspective.
@bacon-cheeseburger thanks, it was a pleasure working with you.
|
I have to wonder about the scope of the PR. Reading a bit between the lines, the goal seems to be to provide enough information to an external program that wants to open a database used by a running Kodi instance. The database name is not enough to establish a connection. In the case of sqlite, the path is required as well and mysql/mariadb require host name, user and password at a minimum. So it seems to me that the "host" part of DatabaseSettings needs to be exposed as well, probably as a tuple with the db name. |
|
Also accepting a string db type is not very robust but I don't know if it's possible to define constants or enums for json or python. |
Well, I think we need to take a step back here and first need to clarify on the points @CrystalP brought up wrt completeness of functionality, and security concerns. |
|
If you assume the external program already has access to path/hostname/user/password through other means, then it can also know the custom base names (if any), ssl parameters, etc. |
I wasn't aware sqlite required a path to login (using mariadb here) but if so then it sounds like something to consider, especially if it can vary at the profile level. The db name in-use is generated internally and required for db access. It can change behind-the-scene via api version change so it makes sense for a way to ask Kodi what the current db name in-use is. The hostname could be exposed without concern imo. I wouldn't recommend exposing login/password, if not necessarily for security but as a matter of generally bad practice. I think it's a reasonable barrier-to-entry that they know the login/password as a prerequisite without Kodi telling them. |
I think it's better to provide the exact database name in-use given Kodi already knows it and there's no good reason I can see in making the user generate it themself. |
55b112c to
f0c99ae
Compare
f0c99ae to
88d3792
Compare
|
Re-did the patch set based on Ksooo's refactor. |
Can you please fix the commit message. It reflects what was in an earlier iteration of my work, not what is in the patch I sent you which is now part of this PR. Should read: "[databasemanager] Add CDatabaseManager::GetDatabaseNameByType()" |
There was a problem hiding this comment.
Pull Request Overview
This pull request adds functionality to retrieve the full database names currently in use by a running Kodi instance. The implementation provides both JSON-RPC API endpoints and Python API functions to access database names for different database types (addons, epg, music, textures, tv, videos, viewmodes).
Key changes:
- Added database type constants and management infrastructure to track database names
- Implemented JSON-RPC
Database.GetDatabaseNamemethod and Pythonxbmc.getDatabaseName()function - Enhanced database classes to register their type and track their actual names in use
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| xbmc/DatabaseTypes.h | New header defining database type constants for consistent naming |
| xbmc/DatabaseManager.h | Enhanced to track database details including type and actual name in use |
| xbmc/DatabaseManager.cpp | Updated to store and retrieve database information by type |
| xbmc/interfaces/json-rpc/DatabaseOperations.* | New JSON-RPC operations for database name retrieval |
| xbmc/interfaces/legacy/ModuleXbmc.* | Added Python API function for database name retrieval |
| xbmc/dbwrappers/Database.* | Modified to accept and store database type information |
| Various database classes | Updated constructors to pass database type to base class |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
ddc2023 to
9ab4643
Compare
…base.GetDatabaseName method to return full database names in-use.
f073594 to
368cd6a
Compare
|
@bacon-cheeseburger this needs a rebase |
Description
Add the ability to get the full database names currently in use directly from a running Kodi instance. The prior draft PR for this (#27150) was abandoned in favor of this one which uses better implementation.
Note: I had to recreate my branch and github won't let me reopen the working draft PR (#27174) so I had to make this one. Sorry for any inconvenience.
Motivation and context
In trying to bisect an issue, I've noticed that addons and external tools have a bad habit of assuming the database in use is always the newest. Even worse, sometimes they don't even consider if custom database names were set in AdvancedSettings. Either of those can be problematic. For example, if a Kodi upgrade introduced a schema version change but had to be rolled back for whatever reason, or when running multiple Kodi versions for dev/testing that may use different schema versions. Simply allowing an addon/script (via python api) or external tool (via json-rpc) to get the actual database names currently in use eliminates the problem.
How has this been tested?
Testing was done using curl from command line for the json-rpc methods, and by calling the xbmc python module functions from a simple test addon that prints the database names to a dialog. The correct names were returned in all tests.
What is the effect on users?
These changes allow an addon/script/external tool that directly accesses the database to get the actual database name it should use rather than guessing or assuming. This ensures whatever action is taken, is happening at the correct database. The addition of DatabaseOperations can be expanded for further functionality also.
Screenshots (if appropriate):
Types of change
Checklist: