Databases: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(Updated for v18)
(→‎Database Versions: Put proper name for v21)
 
(22 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Template:DatabasesNavBox}}
{{Template:DatabasesNavBox}}
{{mininav| [[Development]] {{l2| [[Userdata]] }} }}
{{mininav| [[Development]] {{l2| [[Userdata]] }} }}






= Introduction =
= Introduction =
<section begin="intro" />Kodi uses [http://www.sqlite.org/ SQLite], an open source light-weight SQL database-engine, to store all its library related data ('''''[[Music_library|Music]], [[Video_library|Video]]''''', and Program databases). By default, the database files (*.db) are stored in the '''''[[Userdata]]''''' folder, specifically in userdata/Database.
<section begin="intro" />Kodi uses [http://www.sqlite.org/ SQLite], an open source light-weight SQL database-engine, to store all the library, add-on, EPG, textures and PVR related data using a number of specific databases.<section end="intro" /> By default, the database files (*.db) are stored in the '''''[[Kodi data folder]]\[[Userdata]]''''' folder, specifically in \Database\.
 
Performing certain actions on video files will also add content to the database even if it has not been scanned or scraped. For example if you change any OSD setting while watching it, this will be saved in the database as a preference. Resume points are also stored in this database for unscraped videos.<section end="intro" />






= Using the Databases =
= Using the Databases =
Databasess are automatically maintained whenever you use Kodi. You can activate the most powerful database functionality by setting the Content property on all of your media sources, and using Kodi Library Mode. This view mode allows you to browse your media based on the details available in the databases, rather than using simple folder and filenames for details. You can read more about Library Mode for [[Music Library|Music]] and [[Video Library|Video]] files on their respective pages.
The databases are automatically maintained by {{Kodi}}. It is recommended that {{kodi}} users do not access the database without good working knowledge of relational databases and SQL.
 
The following sections detail the database structure, tables, fields and their properties.
 


Database software is required to access the SQL databases. '''[https://sqlitebrowser.org/ DB Browser for SQLite]''' is available for Windows, macOS, Linux and FreeBSD.


== Building SQL Queries ==
SQLite queries can be incredibly powerful (and extraordinarily complicated). If you are not already familiar with SQL syntax, it would probably be a good idea to check out a general tutorial, such as [http://www.1keydata.com/sql/sql.html this one].


For most Kodi development projects, you're going to be doing select statements. "Select" is a SQL command used to gather data (in the form of "rows") out of a SQL database. Your select statement will include:
* A list of all the data fields (columns in the database table) you want for each row.
* A list of all the tables you need to get information from
* A list of comparisons used to narrow down your results. This last component is optional, but it makes sure your results are relevant and is often used to link database entries across multiple tables.


Below are a few sample select statements, so you can see how it works.
= Accessing the Databases with Kodi Python =
 
Many Python plugins (and some scripts) can use the information in the Kodi database to offer users additional convenience and functionality. The easiest way to access the databases via Kodi Python is using '''[[JSON-RPC API]]'''
This query grabs all of the information for every movie in the Video Library.
<pre><nowiki>select * from movie</nowiki></pre>
 
Note that "*" is used to indicate all fields. Also,there is no "where" clause in this statement, so it returns every row in the table.
 
This query narrows down the results to just those movies released in 2007.
<pre><nowiki>select * from movie where c07 = 2007</nowiki></pre>
 
Note that the column containing the movie's release year is labelled simply "c07." The tables further down this page help you find out which columns contain the information you're looking for.
 
This query example is more semantic. Lists your movies including, in this order, internal ID, internal file ID, rating, movie year, IMDB ID, movie name and movie plot.
<pre><nowiki>select idMovie,idFile,c05,c07,c09,c00,c03,c02 from movie;</nowiki></pre>
 
Now the following query is a bit more complex because it joins 3 movie-related tables (movie, files and path) to list a single useful view of your movies. In human language it lists movie ID, movie year, IMDB rating, IMDB ID, movie name and full path of the movie file, ordered by IMDB rating with highest rating appearing first:
<pre><nowiki> select idMovie,c07,c05,c09,c00,path.strPath||files.strFilename from movie, files,path where movie.idFile=files.idFile and files.idPath=path.idPath order by c05 desc;</nowiki></pre>
 
You could also use less than or greater than symbols to get newer or older movies.
 
This query gets just the path and filename of all of the video files from season two of Chuck.
<pre><nowiki></nowiki></pre>
 
If you're not familiar with SQL queries, this query probably looks pretty complicated. It serves as a good demonstration of why there are so many tables in the list below, and how to use them. Many of the elements of a TV show's path and filename and used repeatedly, so SQL allows us to save space and speed up our searches by storing each of those elements just once, in one place, and referencing them repeatedly by the same ID.
 
In this case, the root path that contains your video files is a long string that repeats at the beginning of many files. The name of a TV series, too, is repeated in every single episode of that series, so it makes the most sense to save the series name once (along with all information relevant to the series). We do that in the table tvshow, and every episode of the TV show can access all of that information using just the TV show's ID.
 
 
 
== Accessing the Databases with Kodi Python ==
Many Python plugins (and some scripts) can use the information in the Kodi database to offer users additional convenience and functionality. The easiest way to access the databases via Kodi Python is using [[JSON RPC]]
 
 
 
== Tags ==
Incorporated into the tables below are the related music metadata tags that are read from music files, and the NFO XML tags exported and imported by Kodi.
{{see also | Music tagging | Import-export library | NFO files}}






= Database Versions =
= Database Versions =
<section begin="database versions" />The following tables shows what database version is used for various Kodi versions. This can be useful to see what versions of Kodi can use [[MySQL]] sharing.  
<section begin="database versions" />The following tables shows what database version is used for various Kodi versions. This can be useful to see what versions of Kodi can use '''[[MySQL]]''' sharing.  


{|class="prettytable"
{|class="prettytable"
! Kodi version !! Date !! MyVideos !! MyMusic !! Textures !! Addons !! ViewModes !! TV !! EPG !! ADSP
! Kodi version !! Date !! MyVideos !! MyMusic !! Textures !! Addons !! ViewModes !! TV !! EPG !! ADSP
|-
|-
  | style="width:120px;" | v10- Dharma
  | style="width:120px;" | v10 - Dharma
  | style="width:120px;" | December 2010  
  | style="width:120px;" | December 2010  
  | style="width:80px; text-align:center;" | 37
  | style="width:80px; text-align:center;" | 37
Line 84: Line 38:
  | style="width:60px; text-align:center;" | N/A
  | style="width:60px; text-align:center;" | N/A
|-
|-
  | style="width:120px;" | v11- Eden
  | style="width:120px;" | v11 - Eden
  | style="width:120px;" | March 2012
  | style="width:120px;" | March 2012
  | style="width:80px; text-align:center;" | 60
  | style="width:80px; text-align:center;" | 60
Line 95: Line 49:
  | style="width:60px; text-align:center;" | N/A
  | style="width:60px; text-align:center;" | N/A
|-
|-
  | style="width:120px;" | v12- Frodo
  | style="width:120px;" | v12 - Frodo
  | style="width:120px;" | January 2013  
  | style="width:120px;" | January 2013  
  | style="width:80px; text-align:center;" | 75
  | style="width:80px; text-align:center;" | 75
Line 106: Line 60:
  | style="width:60px; text-align:center;" | N/A
  | style="width:60px; text-align:center;" | N/A
|-
|-
  | style="width:120px;" | v13- Gotham
  | style="width:120px;" | v13 - Gotham
  | style="width:120px;" | May 2014  
  | style="width:120px;" | May 2014  
  | style="width:80px; text-align:center;" | 78
  | style="width:80px; text-align:center;" | 78
Line 117: Line 71:
  | style="width:60px; text-align:center;" | N/A
  | style="width:60px; text-align:center;" | N/A
|-
|-
  | style="width:120px;" | v14- Helix
  | style="width:120px;" | v14 - Helix
  | style="width:120px;" | December 2014  
  | style="width:120px;" | December 2014  
  | style="width:80px; text-align:center;" | 90
  | style="width:80px; text-align:center;" | 90
Line 128: Line 82:
  | style="width:60px; text-align:center;" | N/A
  | style="width:60px; text-align:center;" | N/A
|-
|-
  | style="width:120px;" | v15- Isengard
  | style="width:120px;" | v15 - Isengard
  | style="width:120px;" | July 2015  
  | style="width:120px;" | July 2015  
  | style="width:80px; text-align:center;" | 93
  | style="width:80px; text-align:center;" | 93
Line 139: Line 93:
  | style="width:60px; text-align:center;" | N/A
  | style="width:60px; text-align:center;" | N/A
|-
|-
  | style="width:120px;" | v16- Jarvis
  | style="width:120px;" | v16 - Jarvis
  | style="width:120px;" | February 2016  
  | style="width:120px;" | February 2016  
  | style="width:80px; text-align:center;" | 99
  | style="width:80px; text-align:center;" | 99
Line 150: Line 104:
  | style="width:60px; text-align:center;" | 0
  | style="width:60px; text-align:center;" | 0
|-
|-
  | style="width:120px;" | v17- Krypton
  | style="width:120px;" | v17 - Krypton
  | style="width:120px;" | February 2017
  | style="width:120px;" | February 2017
  | style="width:80px; text-align:center;" | 107
  | style="width:80px; text-align:center;" | 107
Line 161: Line 115:
  | style="width:60px; text-align:center;" | 0
  | style="width:60px; text-align:center;" | 0
|-
|-
  | style="width:120px;" | v18- Alpha 1
  | style="width:120px;" | v18 - Leia
  | style="width:120px;" | December 2016
  | style="width:120px;" | January 2019
  | style="width:80px; text-align:center;" | 109
  | style="width:80px; text-align:center;" | 116
  | style="width:80px; text-align:center;" | 70
  | style="width:80px; text-align:center;" | 72
  | style="width:80px; text-align:center;" | 13
  | style="width:80px; text-align:center;" | 13
  | style="width:80px; text-align:center;" | 27
  | style="width:80px; text-align:center;" | 27
  | style="width:80px; text-align:center;" | 6
  | style="width:80px; text-align:center;" | 6
  | style="width:60px; text-align:center;" | 32
  | style="width:60px; text-align:center;" | 32
  | style="width:60px; text-align:center;" | 11
  | style="width:60px; text-align:center;" | 12
  | style="width:60px; text-align:center;" | 0
  | style="width:60px; text-align:center;" | 0
|-
| style="width:120px;" | v19 - Matrix
| style="width:120px;" | December 2020
| style="width:80px; text-align:center;" | 119
| style="width:80px; text-align:center;" | 82
| style="width:80px; text-align:center;" | 13
| style="width:80px; text-align:center;" | 33
| style="width:80px; text-align:center;" | 6
| style="width:60px; text-align:center;" | 38
| style="width:60px; text-align:center;" | 13
| style="width:60px; text-align:center;" | N/A
|-
| style="width:120px; background: #a0e75a;" | v20 - Nexus
| style="width:120px; background: #a0e75a;" | 11 January 2023
| style="width:80px; text-align:center; background: #a0e75a;" | 121
| style="width:80px; text-align:center; background: #a0e75a;" | 82
| style="width:80px; text-align:center; background: #a0e75a;" | 13
| style="width:80px; text-align:center; background: #a0e75a;" | 33
| style="width:80px; text-align:center; background: #a0e75a;" | 6
| style="width:60px; text-align:center; background: #a0e75a;" | 40
| style="width:60px; text-align:center; background: #a0e75a;" | 16
| style="width:60px; text-align:center; background: #a0e75a;" | N/A
|-
| style="width:120px; background: skyBlue;" | v21 - Omega
| style="width:120px; background: skyBlue;" | TBD
| style="width:80px; text-align:center; background: skyBlue;" | TBD
| style="width:80px; text-align:center; background: skyBlue;" | TBD
| style="width:80px; text-align:center; background: skyBlue;" | TBD
| style="width:80px; text-align:center; background: skyBlue;" | TBD
| style="width:80px; text-align:center; background: skyBlue;" | TBD
| style="width:60px; text-align:center; background: skyBlue;" | TBD
| style="width:60px; text-align:center; background: skyBlue;" | TBD
| style="width:60px; text-align:center; background: skyBlue;" | TBD
|}
{| class="prettytable"
|-
! colspan="2"| Legend
|-
| style="background:#a0e75a;"| Green
| Current release
|-
| style="background:skyBlue;"| Blue
| Future release
|}
|}
<section end="database versions" />
<section end="database versions" />


 
= See also =
== Links ==
* [[Releases]]
* http://www.rieter.net/content/xot/xbmc-database-versions/ - another site keeping track of Kodi DB changes
* https://github.com/xbmc/xbmc/commits/master/xbmc/video/VideoDatabase.cpp - Tracking the Video Database schema version
* https://github.com/xbmc/xbmc/commits/master/xbmc/video/VideoDatabase.cpp - Tracking the Video Database schema version
* https://github.com/xbmc/xbmc/commits/master/xbmc/music/MusicDatabase.cpp - Tracking the Music Database schema version
* https://github.com/xbmc/xbmc/commits/master/xbmc/music/MusicDatabase.cpp - Tracking the Music Database schema version
== See also ==
* [[Releases]]




Line 192: Line 182:


{{Top}}
{{Top}}
{{updated|20}}


{{updated|18}}
[[Category:PVR]]
[[Category:PVR]]
[[Category:Index]]
[[Category:Manual]]
[[Category:Add-ons]]
[[Category:Add-ons]]
[[Category:Live_TV]]
[[Category:Karellen]]
[[Category:Karellen]]
[[Category:Development]]
[[Category:Development]]
[[Category:Video library]]
[[Category:Video library]]
[[Category:Music library]]
[[Category:Music library]]
[[Category:Advanced topics]]
[[Category:Skin_development]]

Latest revision as of 23:21, 23 December 2023

Kodi Databases

See also:

Home icon grey.png   ▶ Development
▶ Userdata
▶ Databases


Introduction

Kodi uses SQLite, an open source light-weight SQL database-engine, to store all the library, add-on, EPG, textures and PVR related data using a number of specific databases. By default, the database files (*.db) are stored in the Kodi data folder\Userdata folder, specifically in \Database\.


Using the Databases

The databases are automatically maintained by Kodi. It is recommended that Kodi users do not access the database without good working knowledge of relational databases and SQL.

Database software is required to access the SQL databases. DB Browser for SQLite is available for Windows, macOS, Linux and FreeBSD.


Accessing the Databases with Kodi Python

Many Python plugins (and some scripts) can use the information in the Kodi database to offer users additional convenience and functionality. The easiest way to access the databases via Kodi Python is using JSON-RPC API


Database Versions

The following tables shows what database version is used for various Kodi versions. This can be useful to see what versions of Kodi can use MySQL sharing.

Kodi version Date MyVideos MyMusic Textures Addons ViewModes TV EPG ADSP
v10 - Dharma December 2010 37 7 1 1 1 N/A N/A N/A
v11 - Eden March 2012 60 18 6 15 4 N/A N/A N/A
v12 - Frodo January 2013 75 32 13 15 4 22 7 N/A
v13 - Gotham May 2014 78 46 13 16 6 22 7 N/A
v14 - Helix December 2014 90 48 13 16 6 26 8 N/A
v15 - Isengard July 2015 93 52 13 19 6 29 10 N/A
v16 - Jarvis February 2016 99 56 13 20 6 29 11 0
v17 - Krypton February 2017 107 60 13 27 6 29 11 0
v18 - Leia January 2019 116 72 13 27 6 32 12 0
v19 - Matrix December 2020 119 82 13 33 6 38 13 N/A
v20 - Nexus 11 January 2023 121 82 13 33 6 40 16 N/A
v21 - Omega TBD TBD TBD TBD TBD TBD TBD TBD TBD
Legend
Green Current release
Blue Future release


See also



Return to top