Question About Kodi & MySQL
#1
I'm not sure what would be the best place to post regarding this issue, so mods, please move this topic or notify me as needed.

I'm using a single MySQL database server to host my Kodi libraries, which are then accessed by several instances of Kodi 14.0.

Lately I have been messing around with interacting with the database directly using Python. This has been a lot of fun, but as I got further into manipulating my databases, one question came up: when adding / removing rows from a table, how does Kodi handle the generation of unique IDs? It looks like most tables have a unique ID value, like the art table has art_id, actors has idActor, etc. For most of the basic stuff, it looks like a new row gets assigned the next unused sequential integer. I'm currently looking at add/removing rows from the art table, but I'm curious how Kodi handles this in the broader context as well.

I'm aware that when attempting to determine what next value is currently unused, I must handle possible concurrence issues.
Catchy Signature Here
Reply
#2
We don't use any logic to determine the next unused ID ourselves. That's a feature that is provided by the SQL database (SQLite or MySQL) using AUTO INCREMENT. That way you also don't have to care about concurrence issues as the database takes care of it.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#3
That's what I needed, thank you! I can see why this was done, this mechanism is perfect for use-cases like this. I'm still very much a SQL newbie, which is part of why I'm doing this project as a tangible way to teach myself some basics.
Catchy Signature Here
Reply

Logout Mark Read Team Forum Stats Members Help
Question About Kodi & MySQL0