Databases: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(Updated Video Tables to MyVideos107.db schema)
m (→‎Database Versions: update month)
(46 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{mininav| [[Development]] {{l2| [[userdata folder]] }} }}
{{Template:DatabasesNavBox}}
{{see also|Databases/Versions}}
{{mininav| [[Development]] {{l2| [[Userdata]] }} }}


<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.


In addition to indexing media files when activated by user-selected Content settings, Kodi also puts a video in its database if you change any OSD setting while watching it. Resume points are stored in this database as well. These entries are added to the database whether the affected video is part of the Video Library or not.<section end="intro" />


== 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.


Since Kodi maintains the databases on its own, the only time a developer really needs to access the databases is for display information. The following sections discuss how you can access the information contained in Kodi's databases, and give some brief examples of how to use it.
= 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.


=== Building SQL Queries ===
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 =
Databases 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 following sections detail the database structure, tables, fields and their properties.
 
 
 
== 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].
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:
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 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 all the tables you need to get information from
Line 24: Line 31:
This query grabs all of the information for every movie in the Video Library.  
This query grabs all of the information for every movie in the Video Library.  
<pre><nowiki>select * from movie</nowiki></pre>
<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.
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.  
This query narrows down the results to just those movies released in 2007.  
<pre><nowiki>select * from movie where c07 = 2007</nowiki></pre>
<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.  
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.  


Line 40: Line 49:
This query gets just the path and filename of all of the video files from season two of Chuck.
This query gets just the path and filename of all of the video files from season two of Chuck.
<pre><nowiki></nowiki></pre>
<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.
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.
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]]


== The Music Library ==
This database contains all information concerning music files that you've added to the Music Library. It is used in the Music portion of Kodi. The following information is for version 32.


The music database is stored in userdata/Database/MyMusicXX.db, where XX is the version number.
== 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]]


=== Views ===
Views are standard queries, often long or complicated queries saved in the database for convenience. The views below allow you to easily access all the information about songs and albums in the Music Library, across all the linking tables.


==== albumview ====
A view of the album table with some additional fields aggregated from the songs of that album.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idAlbum || integer || ID from Album Table
|-
|strAlbum || varchar(256) || Album Name
|-
|strMusicBrainzAlbumID || text || MusicBrainz Album ID
|-
|strArtists || text || Album Artists
|-
|strGenres || text || Album Genres
|-
|iYear || integer || Album Release Year
|-
|strMoods || text || Album Moods
|-
|strStyles || text || Album Styles
|-
|strThemes || text || Album Themes
|-
|strReview || text || Album Review
|-
|strLabel || text || Album Recording Label
|-
|strType || text || Album Type e.g. "Soundtrack / Live"
|-
|strImage || text || URL for Album Image
|-
|fRating || float || Album rating
|-
|iRating || integer || Album user rating
|-
|iVotes || integer || Album votes (for rating)
|-
|bCompilation || integer || Compilation flag
|-
|iTimesPlayed || integer ||Average of number of times songs on album are played
|-
|strReleaseType || text || Internal type - "album" or "single"
|-
|dateAdded || text || Music file timestamp of newest song on album
|-
|lastPlayed || text || Date any song on album was last played
|}


==== artistview ====
== Tags ==
A view that joins artist to artistinfo.
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.
{|class="prettytable"
{{see also | Music tagging | Import-export library | NFO files}}
! Column Name || Data Type || Description
|-
|idArtist || integer || ID from Artist Table
|-
|strArtist || varchar(256) || Artist Name
|-
|strBorn || text || Artist Birthday
|-
|strFormed || text || Band Formation Date
|-
|strGenres || text || Artist Genres
|-
|strMoods || text || Artist Moods
|-
|strStyles || text || Artist Styles
|-
|strInstruments || text || Artist Instruments
|-
|strBiography || text || Artist Biography
|-
|strDied || text || Artist Date Died
|-
|strDisbanded || text || Band Disbanded Date
|-
|strYearsActive || text || Years Artist is Active
|-
|strImage || text || URL of Artist Image
|-
|strFanart || text || URL of Fanart
|}


==== songview ====
A view that joins song to album, path, artist, genre, thumb, and karaokedata.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idSong || integer || ID from Song Table
|-
|strArtists || text || Song Artists
|-
|strGenres || text || Song Genres
|-
|strTitle || varchar(512) || Song Title
|-
|iTrack || integer || Song Track Number
|-
|iDuration || integer || Song Duration in seconds
|-
|iYear || integer || Song's Release Year
|-
|dwFileNameCRC || text || [unknown]
|-
|strMusicBrainzTrackID || text || Song's MusicBrainz Track ID
|-
|strMusicBrainzArtistID || text || Song's MusicBrainz Artist ID
|-
|strMusicBrainzAlbumID || text || Song's MusicBrainz Album ID
|-
|strMusicBrainzAlbumArtistID || text || Song's MusicBrainz Album Artist ID
|-
|strMusicBrainzTRMID || text || [unknown]
|-
|iTimesPlayed || integer || # of Times Played
|-
|iStartOffset || integer || [unknown]
|-
|iEndOffset || integer  || [unknown]
|-
|idThumb || integer || [unknown]
|-
|lastplayed || varchar(20) || Date & Time Last Played
|-
|rating || char || Song Rating
|-
|comment || text || Song Comment
|-
|idAlbum || integer || ID from Album Table
|-
|strAlbum || varchar(256) || Album Name
|-
|strPath || varchar(512) || Media Path
|-
|iKaraNumber || integer || [unknown]
|-
|iKaraDelay || integer || [unknown]
|-
|strKaraEncoding || text || [unknown]
|-
|bCompilation || integer || [unknown]
|-
|strAlbumArtists || text || Album Artists
|}


=== Tables ===


==== album ====
= Database Versions =
An album.
<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"
! Column Name || Data Type || Description
|-
|idAlbum || integer || Primary Key
|-
|strAlbum || varchar(256) || Album Name
|-
|strMusicBrainzAlbumID || text || MusicBrainz Album ID
|-
|strArtists || text || Album Artist Names (denormalized)
|-
|strGenres || text || Album Genres (denormalized)
|-
|iYear || integer || Album Year
|-
|idThumb || integer || Foreign key to [[Databases#thumb(music)|thumb table]]
|-
|bCompilation || integer || Compilation flag
|-
|strMoods || text || Album Moods
|-
|strStyles || text || Album Styles
|-
|strThemes || text || Album Themes
|-
|strReview || text || Album Review
|-
|strImage || text || URL for Album Image
|-
|strLabel || text || Album Recording Label
|-
|strType || text || Album Type e.g. "Soundtrack / Live"
|-
|fRating || float || Album rating
|-
|iRating || integer || Album user rating
|-
|lastScraped || text || Date/time data scraped from online sources or NFO files
|-
|strReleaseType || text || Internal type - "album" or "single"
|-
|iVotes || integer || Album votes (for rating)
|}
 
==== album_artist ====
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idArtist || integer || Foreign key to [[Databases#artist|artist table]]
|-
|idAlbum || integer || Foreign key to [[Databases#album|album table]]
|-
|iOrder || integer || Order of artist names for credits
|}
 
==== album_genre ====
This links albums with their genres.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idGenre || integer || Foreign key to [[Databases#genre(music)|genre(music) table]]
|-
|idAlbum || integer || Foreign key to [[Databases#album|album table]]
|-
|iOrder || integer || [unknown]
|}
 
==== albuminfo ====
This table contains additional information about an album, such as Rating, Moods, Styles, Reviews, Image URL, and type.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idAlbumInfo || integer || Primary Key
|-
|idAlbum || integer || Foreign key to [[Databases#album|album table]]
|-
|iYear || integer || Album Year
|-
|strMoods || text || Album Moods
|-
|strStyles || text || Album Styles
|-
|strThemes || text || Album Themes
|-
|strReview || text || Album Review
|-
|strImage || text || URL of Album Image
|-
|strLabel || text || Album Label
|-
|strType || text || Album Type
|-
|iRating || integer || Album Rating
|}
 
==== albuminfosong ====
This table links songs to albums and stores the duration of each track.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idAlbumInfoSong || integer || Primary Key
|-
|idAlbumInfo || integer || Foreign key to [[Databases#albuminfo|albuminfo table]]
|-
|iTrack || integer || Track #
|-
|strTitle || text || Song Title
|-
|iDuration || integer || Song Duration in seconds
|}
 
==== art ====
{|class="prettytable"
! Column Name || Data Type || Description
|-
|art_id || integer || Primary Key
|-
|media_id || integer || [unknown]
|-
|media_type || text || [unknown]
|-
|type || text || [unknown]
|-
|url || text || [unknown]
|}
 
==== artist ====
This table stores the name of each artist.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idArtist || integer || Primary Key
|-
|strArtist || varchar(256) || Artist Name
|}


==== artistinfo ====
This table stores relevant information about each artist, such as when they were born, Fan Art URL's, biographical information, etc.
{|class="prettytable"
{|class="prettytable"
! Column Name || Data Type || Description
! Kodi version !! Date !! MyVideos !! MyMusic !! Textures !! Addons !! ViewModes !! TV !! EPG !! ADSP
|-
|-
|idArtistInfo || integer || Primary Key
| style="width:120px;" | v10 - Dharma
| style="width:120px;" | December 2010
| style="width:80px; text-align:center;" | 37
| style="width:80px; text-align:center;" | 7
| style="width:80px; text-align:center;" | 1
| style="width:80px; text-align:center;" | 1
| style="width:80px; text-align:center;" | 1
| style="width:60px; text-align:center;" | N/A
| style="width:60px; text-align:center;" | N/A
| style="width:60px; text-align:center;" | N/A
|-
|-
|idArtist || integer || Foreign key to [[Databases#artist|artist table]]
| style="width:120px;" | v11 - Eden
| style="width:120px;" | March 2012
| style="width:80px; text-align:center;" | 60
| style="width:80px; text-align:center;" | 18
| style="width:80px; text-align:center;" | 6
| style="width:80px; text-align:center;" | 15
| style="width:80px; text-align:center;" | 4
| style="width:60px; text-align:center;" | N/A
| style="width:60px; text-align:center;" | N/A
| style="width:60px; text-align:center;" | N/A
|-
|-
|strBorn || text || Artist Birthday
| style="width:120px;" | v12 - Frodo
| style="width:120px;" | January 2013
| style="width:80px; text-align:center;" | 75
| style="width:80px; text-align:center;" | 32
| style="width:80px; text-align:center;" | 13
| style="width:80px; text-align:center;" | 15
| style="width:80px; text-align:center;" | 4
| style="width:60px; text-align:center;" | 22
| style="width:60px; text-align:center;" | 7
| style="width:60px; text-align:center;" | N/A
|-
|-
|strFormed || text || Band Formation Date
| style="width:120px;" | v13 - Gotham
| style="width:120px;" | May 2014
| style="width:80px; text-align:center;" | 78
| style="width:80px; text-align:center;" | 46
| style="width:80px; text-align:center;" | 13
| style="width:80px; text-align:center;" | 16
| style="width:80px; text-align:center;" | 6
| style="width:60px; text-align:center;" | 22
| style="width:60px; text-align:center;" | 7
| style="width:60px; text-align:center;" | N/A
|-
|-
|strGenres || text || Artist Genres
| style="width:120px;" | v14 - Helix
| style="width:120px;" | December 2014
| style="width:80px; text-align:center;" | 90
| style="width:80px; text-align:center;" | 48
| style="width:80px; text-align:center;" | 13
| style="width:80px; text-align:center;" | 16
| style="width:80px; text-align:center;" | 6
| style="width:60px; text-align:center;" | 26
| style="width:60px; text-align:center;" | 8
| style="width:60px; text-align:center;" | N/A
|-
|-
|strMoods || text || Artist Moods
| style="width:120px;" | v15 - Isengard
| style="width:120px;" | July 2015
| style="width:80px; text-align:center;" | 93
| style="width:80px; text-align:center;" | 52
| style="width:80px; text-align:center;" | 13
| style="width:80px; text-align:center;" | 19
| style="width:80px; text-align:center;" | 6
| style="width:60px; text-align:center;" | 29
| style="width:60px; text-align:center;" | 10
| style="width:60px; text-align:center;" | N/A
|-
|-
|strStyles || text || Artist Styles
| style="width:120px;" | v16 - Jarvis
| style="width:120px;" | February 2016
| style="width:80px; text-align:center;" | 99
| style="width:80px; text-align:center;" | 56
| style="width:80px; text-align:center;" | 13
| style="width:80px; text-align:center;" | 20
| style="width:80px; text-align:center;" | 6
| style="width:60px; text-align:center;" | 29
| style="width:60px; text-align:center;" | 11
| style="width:60px; text-align:center;" | 0
|-
|-
|strInstruments || text || Artist's Instruments
| style="width:120px;" | v17 - Krypton
| style="width:120px;" | February 2017
| style="width:80px; text-align:center;" | 107
| style="width:80px; text-align:center;" | 60
| style="width:80px; text-align:center;" | 13
| style="width:80px; text-align:center;" | 27
| style="width:80px; text-align:center;" | 6
| style="width:60px; text-align:center;" | 29
| style="width:60px; text-align:center;" | 11
| style="width:60px; text-align:center;" | 0
|-
|-
|strBiography || text || Artist's Biography
| style="width:120px; background:#a0e75a;" | v18 - Leia
| style="width:120px; background:#a0e75a;" | January 2019
| style="width:80px; text-align:center; background:#a0e75a;" | 116
| style="width:80px; text-align:center; background:#a0e75a;" | 72
| style="width:80px; text-align:center; background:#a0e75a;" | 13
| style="width:80px; text-align:center; background:#a0e75a;" | 27
| style="width:80px; text-align:center; background:#a0e75a;" | 6
| style="width:60px; text-align:center; background:#a0e75a;" | 32
| style="width:60px; text-align:center; background:#a0e75a;" | 12
| style="width:60px; text-align:center; background:#a0e75a;" | 0
|-
|-
|strDied || text || Artist Date Died
| style="width:120px; background: skyBlue;" | v19 - Matrix
|-
| style="width:120px; background: skyBlue;" | December 2020
|strDisbanded || text || Band Disbanded Date
| style="width:80px; text-align:center; background: skyBlue;" | 119
|-
| style="width:80px; text-align:center; background: skyBlue;" | 82
|strYearsActive || text || Years Artist is Active
| style="width:80px; text-align:center; background: skyBlue;" | 13
|-
| style="width:80px; text-align:center; background: skyBlue;" | 33
|strImage || text || URL of Artist Image
| style="width:80px; text-align:center; background: skyBlue;" | 6
|-
| style="width:60px; text-align:center; background: skyBlue;" | 37
|strFanart || text || URL of Fanart
| style="width:60px; text-align:center; background: skyBlue;" | 13
| style="width:60px; text-align:center; background: skyBlue;" | N/A
|}
|}


==== content ====
{| class="prettytable"
This table is related to the scraper.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|strPath || text || [unknown]
|-
|-
|strScraperPath || text || [unknown]
! colspan="2"| Legend
|-
|-
|strContent || text || [unknown]
| style="background:#a0e75a;"| Green
| Current release
|-
|-
|strSettings || text || [unknown]
| style="background:skyBlue;"| Blue
| Future release
|}
|}
<section end="database versions" />


==== discography ====
Links albums to artists with the year produced.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idArtist || integer || Foreign key to [[Databases#artist|artist table]]
|-
|strAlbum || text || Album Name
|-
|strYear || text || Year Album Produced.
|}


==== exartistablum ====
Links artists to albums


==== exartistsong ====
== Links ==
Links artists to songs
* 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/music/MusicDatabase.cpp - Tracking the Music Database schema version


==== exgenrealbum ====
Links genres to albums


==== exgenresong ====
Links genres to songs


==== genre(music) ====
== See also ==
This table contains genre titles.
* [[Releases]]
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idGenre || integer || Primary Key
|-
|strGenre || varchar(256) || Genre Name
|}
 
==== karaokedata ====
This table contains karaoke specific information for certain songs
{|class="prettytable"
! Column Name || Data Type || Description
|-
|iKaraNumber || integer || [unknown]
|-
|idSong || integer || Foreign key to [[Databases#song|song table]]
|-
|iKaraDelay || integer || [unknown]
|-
|strKaraEncoding || text || [unknown]
|-
|strKaralyrics || text || [unknown]
|-
|strKaraLyFileCRC || text || [unknown]
|}
 
==== path(music) ====
This table contains paths and hashes of files in the Music Database.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idPath || integer || Primary Key
|-
|strPath || varchar(512) || Media Paths
|-
|strHash || text || [unknown]
|}
 
==== song ====
This table contains song information such as Name, Track Title, MusicBrainz information, times played, last played, rating, etc.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idSong || integer || Primary Key
|-
|idAlbum || integer || Foreign key to [[Databases#album|album table]]
|-
|idPath || integer || Foreign key to [[Databases#path|path table]]
|-
|strArtists || text || Song Artists
|-
|strGenres || text || Song Genres
|-
|strTitle || varchar(512) || Song Title
|-
|iTrack || integer || Song Track Number
|-
|iDuration || integer || Song Duration in seconds
|-
|iYear || integer || Song's Release Year
|-
|dwFileNameCRC || text || [unknown]
|-
|strMusicBrainzTrackID || text || Song's MusicBrainz Track ID
|-
|strMusicBrainzArtistID || text || Song's MusicBrainz Artist ID
|-
|strMusicBrainzAlbumID || text || Song's MusicBrainz Album ID
|-
|strMusicBrainzAlbumArtistID || text || Song's MusicBrainz Album Artist ID
|-
|strMusicBrainzTRMID || text || [unknown]
|-
|iTimesPlayed || integer || # of Times Played
|-
|iStartOffset || integer || [unknown]
|-
|iEndOffset || integer  || [unknown]
|-
|idThumb || integer || Foreign key to [[Databases#thumb|thumb table]]
|-
|lastplayed || varchar(20) || Date & Time Last Played
|-
|rating || char || Song Rating
|-
|comment || text || Song Comment
|}
 
==== song_artist ====
This table links songs to artists.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idArtist || integer || Foreign key to [[Databases#artist|artist table]]
|-
|idSong || integer || Foreign key to [[Databases#song|song table]]
|-
|boolFeatured || integer || Is Artist Featured on song?
|-
|iOrder || integer || [unknown]
|}
 
==== song_genre ====
This table links the songs with their genre.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idGenre || integer || Foreign key to [[Databases#genre(music)|genre(music) table]]
|-
|idSong || integer || Foreign key to [[Databases#song|song table]]
|-
|iOrder || integer || [unknown]
|}
 
==== thumb ====
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idThumb || integer || Primary Key
|-
|strThumb || text || [unknown]
|}
 
==== version(music) ====
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idVersion || integer || Version of the music database
|-
|idCompressCount || integer || Number of times database has been compressed
|}
 
== The Video Library ==
This database contains all information concerning TV shows, movies, and music videos. It is used in the Videos portion of Kodi. The following information is for version 75.
 
The video database is stored in userdata/Database/MyVideosXX.db, where XX is the version number.
 
=== Views ===
Views are standard queries, often long or complicated queries saved in the database for convenience. The views below allow you to easily access all the information about each of the main media types in the Video Library, across all the linking tables.
 
==== episodeview ====
A view that joins episode to file and tvshow (through tvshowlinkepisode) and path.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idEpisode || integer || Primary Key
|-
|idFile || integer ||  Foreign key to the [[Databases#files|files table]]
|-
|c00 || text ||  Episode Title
|-
|c01 || text ||  Plot Summary
|-
|c02 || text ||  [unknown - listed as Votes]
|-
|c03 || text ||  Rating
|-
|c04 || text ||  Writer
|-
|c05 || text ||  First Aired
|-
|c06 || text ||  Thumbnail URL
|-
|c07 || text ||  [unknown - listed as Thumbnail URL Spoof, unused?]
|-
|c08 || text ||  Has the episode been watched? (unused?)
|-
|c09 || text ||  Episode length in minutes
|-
|c10 || text ||  Director
|-
|c11 || text ||  [unknown - listed as Indentifier]
|-
|c12 || text ||  Season Number
|-
|c13 || text ||  Episode Number
|-
|c14 || text ||  [unknown - listed as Original Title, unused?]
|-
|c15 || text ||  Season formatted for sorting
|-
|c16 || text ||  Episode formatted for sorting
|-
|c17 || text ||  Bookmark
|-
|c18 || text ||  Not used
|-
|c19 || text ||  Not used
|-
|c20 || text ||  Not used
|-
|idShow || integer ||  Foreign key to the [[Databases#tvshow|tvshow table]]
|-
|strFileName || text || Full name of file including extension
|-
|strPath || text || Path URL
|-
|playCount || integer || # of Times Played
|-
|lastPlayed || text || Date & Time Last Played
|-
|dateAdded || text || Date & Time Added to Library
|-
|strTitle || text || Episode Title
|-
|strStudio || text || Network
|-
|premiered || text || First Aired
|-
|mpaa || text || Content Rating
|-
|strShowPath || text || Show Path URL
|-
|resumeTimeInSeconds || double || Time in seconds of bookmark location
|-
|totalTimeInSeconds || double || Time in seconds of the video
|-
|idSeason || integer || Foreign key to the [[Databases#seasons|seasons table]]
|}
 
==== movieview ====
A view that joins movie to file and path.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idMovie || integer || Primary Key
|-
|idFile || integer || Foreign Key to [[Databases#files|files table]]
|-
|c00 || text ||  Local Movie Title
|-
|c01 || text || Movie Plot
|-
|c02 || text ||  Movie Plot Outline
|-
|c03 || text ||  Movie Tagline
|-
|c04 || text ||  Rating Votes
|-
|c05 || text ||  Rating
|-
|c06 || text ||  Writers
|-
|c07 || text ||  Year Released
|-
|c08 || text ||  Thumbnails
|-
|c09 || text ||  IMDB ID
|-
|c10 || text ||  Title formatted for sorting
|-
|c11 || text ||  Runtime (UPnP devices see this as seconds)
|-
|c12 || text ||  MPAA Rating
|-
|c13 || text ||  [http://www.imdb.com/chart/top IMDB Top 250] Ranking
|-
|c14 || text ||  Genre
|-
|c15 || text ||  Director
|-
|c16 || text ||  Original Movie Title
|-
|c17 || text ||  [unknown - listed as Thumbnail URL Spoof]
|-
|c18 || text ||  Studio
|-
|c19 || text ||  Trailer URL
|-
|c20 || text ||  Fanart URLs
|-
|c21 || text ||  Country (Added in r29886[http://trac.kodi.tv/changeset/29886/trunk])
|-
|c23 || text ||  idPath
|-
|idSet || integer ||  Foreign Key to [[Databases#sets|sets table]]
|-
|strSet || text || The name of the set
|-
|strFileName || text || Full name of file including extension
|-
|strPath || text || Path URL
|-
|playCount || integer || # of Times Played
|-
|lastPlayed || text || Date & Time Last Played
|-
|dateAdded || text || Date & Time Added to Library
|-
|resumeTimeInSeconds || double || Time in seconds of bookmark location
|-
|totalTimeInSeconds || double || Time in seconds of the video
|}
 
==== musicvideoview ====
A view that joins musicvideo to file and path.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idMVideo || integer || Primary Key
|-
|idFile || integer ||  Foreign Key to [[Databases#files|files table]]
|-
|c00 || text || Title
|-
|c01 || text || Thumbnail URL
|-
|c02 || text || [unknown - listed as Thumbnail URL spoof]
|-
|c03 || text || Play count (unused?)
|-
|c04 || text || Run time
|-
|c05 || text || Director
|-
|c06 || text || Studios
|-
|c07 || text || Year
|-
|c08 || text || Plot
|-
|c09 || text || Album
|-
|c10 || text || Artist
|-
|c11 || text || Genre
|-
|c12 || text || Track
|-
|c13 || text ||
|-
|c14 || text ||
|-
|c15 || text ||
|-
|c16 || text ||
|-
|c17 || text ||
|-
|c18 || text ||
|-
|c19 || text ||
|-
|c20 || text ||
|-
|c21 || text ||
|-
|c22 || text ||
|-
|c23 || text ||
|-
|strFileName || text || Full name of file including extension
|-
|strPath || text || Path URL
|-
|playCount || integer || # of Times Played
|-
|lastPlayed || text || Date & Time Last Played
|-
|dateAdded || text || Date & Time Added to Library
|-
|resumeTimeInSeconds || double || Time in seconds of bookmark location
|-
|totalTimeInSeconds || double || Time in seconds of the video
|}
 
==== tvshowview ====
View that joins tvshow to path. Also produces information about total number of episodes as well as number of watched and unwatched episodes.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idShow || integer || Primary Key
|-
|c00 || text ||  Show Title
|-
|c01 || text || Show Plot Summary
|-
|c02 || text ||  Status
|-
|c03 || text ||  Votes
|-
|c04 || text ||  Rating
|-
|c05 || text ||  First Aired
|-
|c06 || text ||  Thumbnail URL
|-
|c07 || text ||  [unknown - Spoof Thumbnail URL?]
|-
|c08 || text ||  Genre
|-
|c09 || text ||  Original Title
|-
|c10 || text ||  Episode Guide URL
|-
|c11 || text ||  Fan Art URL
|-
|c12 || text ||  SeriesId (when using thetvdb.com scraper)
|-
|c13 || text ||  Content Rating
|-
|c14 || text ||  Network
|-
|c15 || text ||  Title formatted for sorting
|-
|c16 || text ||  Not Used
|-
|c17 || text ||  Not Used
|-
|c18 || text ||  Not Used
|-
|c19 || text ||  Not Used
|-
|c20 || text ||  [unknown]
|-
|c21 || text || [unknown]
|-
|c22 || text || [unknown]
|-
|c23 || text || [unknown]
|-
|strPath || text || Path URL
|-
|dateAdded || text || Date & Time Added to Library
|-
|lastPlayed || text || Date & Time Last Played
|-
|totalCount || integer || # of Episodes
|-
|watchedcount || integer || # of Times Played
|-
|totalSeasons || integer || # of Seasons
|}
 
=== Tables ===
The information in the Video Library is organized into the following tables. Several large tables (such as [[Databases#episode|episode]], [[Databases#movie|movie]], [[Databases#settings|settings]], and [[Databases#tvshow|tvshow]]) contain the bulk of the information, while most of the others are used to link a long string to a common ID key.
 
==== actor ====
This table stores actor, artist, director, and writer information.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|actor_id || integer || Primary Key
|-
|name || integer || Name of the actor, artist, director, or writer
|-
|art_urls|| text || Image URL
|}
 
==== actor_link ====
This table links actors to Movies, TV Shows, Episodes, Music Videos and stores role information.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|actor_id || integer || Foreign key to [[Databases#actors|actors table]]
|-
|media_id || integer || Foreign key to [[Databases#episode|episode table]], [[Databases#tvshow|tv show table]], [[Databases#movie|movie table]],[[Databases#musicvideo|music video table]]
|-
|media_type || text || Movie, TV Show, Episode, Music Video
|-
|role || text || Role the actor played
|-
|cast_order || integer || Order actors will be displayed
|}==== art ====
This table stores URLs for video art metadata.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|art_id || integer || Primary Key
|-
|media_id || integer || The id of the media this piece of art is for
|-
|media_type || text || The type of media this art applies to - movie, set, tvshow, season, episode, musicvideo or actor
|-
|type || text || The image type - poster, fanart, thumb, banner, landscape, clearlogo, clearart, characterart or discart
|-
|url || text || Image URL
|}
 
<!--- HIDDEN UNTIL CONFIRMED REMOVED FROM V17 ==== artistlinkmusicvideo ====
This table links artists to music videos.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idArtist || integer || Foreign key to [[Databases#actors|actors table]]
|-
|idMVideo || integer || Foreign key to [[Databases#musicvideo|musicvideo table]]
|}
--->
==== bookmark ====
This table stores bookmarks, which are timestamps representing the point in a video where a user stopped playback, an explicit bookmark requested by the user, or an automatically generated episode bookmark.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idBookmark || integer || Primary Key
|-
|idFile || integer || Foreign key to [[Databases#files|files table]]
|-
|timeInSeconds || double || Time in seconds of bookmark location
|-
|totalTimeInSeconds || integer || Time in seconds of the video
|-
|thumbNailImage || text || Thumbnail for bookmark
|-
|player || text || Player used to store bookmark
|-
|playerState || text || Player's internal state in XML
|-
|type || integer || Type of bookmark (0=standard, 1=resume, 2=episode)
|}
 
==== country ====
This table lists countries.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|country_id || integer || Primary Key
|-
|name || text || Country Name
|}
 
==== country link ====
This table links countries to movies.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|country_id || integer || Foreign key to [[Databases#country|country table]]
|-
|media_id || integer ||Foreign key to [[Databases#movie|movie table]]
|-
|media_type || integer || Movie
|}
 
==== director_link ====
This table links directors to Movies, TV show episodes and Music Videos
{|class="prettytable"
! Column Name || Data Type || Description
|-
|actor_id || integer || Foreign key to [[Databases#actors|actors table]]
|-
|media_id || integer || Foreign key to [[Databases#episode|episode table]], [[Databases#movie|movie table]],[[Databases#musicvideo|music video table]]
|-
|media_type || text || Movie, Music Video, Episode
|}
 
==== episode ====
This table stores television episode information. Information concerning the series is stored in [[Databases#tvshow|tvshow]]. To link an episode to its parent series, use [[Databases#tvshowlinkepisode|tvshowlinkepisode]].
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idEpisode || integer || Primary Key
|-
|idFile || integer ||  Foreign key to the [[Databases#files|files table]]
|-
|c00 || text ||  Episode Title
|-
|c01 || text ||  Plot Summary
|-
|c02 || text ||  [unknown - listed as Votes]
|-
|c03 || text ||  Rating
|-
|c04 || text ||  Writer
|-
|c05 || text ||  First Aired
|-
|c06 || text ||  Thumbnail URL
|-
|c07 || text ||  [unknown - listed as Thumbnail URL Spoof, unused?]
|-
|c08 || text ||  Has the episode been watched? (unused?)
|-
|c09 || text ||  Episode length in minutes
|-
|c10 || text ||  Director
|-
|c11 || text ||  [unknown - listed as Indentifier]
|-
|c12 || text ||  Season Number
|-
|c13 || text ||  Episode Number
|-
|c14 || text ||  [unknown - listed as Original Title, unused?]
|-
|c15 || text ||  Season formatted for sorting
|-
|c16 || text ||  Episode formatted for sorting
|-
|c17 || text ||  Bookmark
|-
|c18 || text ||  Path to episode file
|-
|c19 || text ||  Used- unknown
|-
|c20 || text ||  Used- unknown
|-
|c21 || text ||  Not used
|-
|c22 || text ||  Not used
|-
|c23 || text ||  Not used
|-
|idShow || text ||  Foreign key to the [[Databases#tvshow|tvshow table]]
|-
|userrating || text ||  User Rating
|-
|idSeason || text ||  Foreign key to the [[Databases#seasons|seasons table]]
|}
 
==== files ====
This table stores filenames and links the path.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idFile || integer || Primary Key
|-
|idPath || integer || Foreign key to [[Databases#path|path table]]
|-
|strFilename || text || Full name of file including extension
|-
|playCount || integer || # of Times Played
|-
|lastPlayed || text || Date & Time Last Played
|-
|dateAdded || text || Date & Time Added to Library
|}
 
==== genre ====
This table stores genre information. For convenience the contents are duplicated in [[Databases#movie|movie]] and [[Databases#tvshow|tvshow]], so a join isn't necessary.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|genre_id || integer || Primary Key
|-
|name || text || Genre label
|}
 
==== genre_link ====
This table links genres to movies. (The contents are also stored in movies.c14, though.)
{|class="prettytable"
! Column Name || Data Type || Description
|-
|genre_id || integer || Foreign key to [[Databases#genre|genre table]]
|-
|media_id || integer || Foreign key to [[Databases#movie|movie table]], [[Databases#tvshow|tv show table]], [[Databases#musicvideo|music video table]]
|-
|media_type || text || Movie, Music Video, TV Show
|}
 
==== movie ====
This table stores movie information.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idMovie || integer || Primary Key
|-
|idFile || integer ||  Foreign Key to [[Databases#files|files table]]
|-
|c00 || text ||  Local Movie Title
|-
|c01 || text ||  Movie Plot
|-
|c02 || text ||  Movie Plot Outline
|-
|c03 || text ||  Movie Tagline
|-
|c04 || text ||  Rating Votes
|-
|c05 || text ||  Rating
|-
|c06 || text ||  Writers
|-
|c07 || text ||  Year Released
|-
|c08 || text ||  Image URL
|-
|c09 || text ||  IMDB ID
|-
|c10 || text ||  Title formatted for sorting
|-
|c11 || text ||  Runtime (UPnP devices see this as seconds)
|-
|c12 || text ||  MPAA Rating
|-
|c13 || text ||  [http://www.imdb.com/chart/top IMDB Top 250] Ranking
|-
|c14 || text ||  Genre
|-
|c15 || text ||  Director
|-
|c16 || text ||  Original Movie Title
|-
|c17 || text ||  [unknown - listed as Thumbnail URL Spoof]
|-
|c18 || text ||  Studio
|-
|c19 || text ||  Trailer URL
|-
|c20 || text ||  Fanart URLs
|-
|c21 || text ||  Country (Added in r29886[http://trac.kodi.tv/changeset/29886/trunk])
|-
|c22 || text ||  Path to playable file
|-
|c23 || text ||  idPath
|-
|idSet || integer ||  Foreign Key to [[Databases#sets|sets table]]
|-
|userrating || integer ||  Rating applied by user
|-
|premiered || text ||  Date movie premiered
|}
 
==== movielinktvshow ====
This table links movies to TV shows.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idMovie || integer || Foreign key to [[Databases#movie|movie table]]
|-
|idShow || integer || Foreign key to [[Databases#tvshow|tvshow table]]
|}
 
==== musicvideo ====
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idMVideo || integer || Primary Key
|-
|idFile || integer ||  Foreign Key to [[Databases#files|files table]]
|-
|c00 || text || Title
|-
|c01 || text || Thumbnail URL
|-
|c02 || text || [unknown - listed as Thumbnail URL spoof]
|-
|c03 || text || Play count (unused?)
|-
|c04 || text || Run time
|-
|c05 || text || Director
|-
|c06 || text || Studios
|-
|c07 || text || Year
|-
|c08 || text || Plot
|-
|c09 || text || Album
|-
|c10 || text || Artist
|-
|c11 || text || Genre
|-
|c12 || text || Track
|-
|c13 || text || Path to playable file
|-
|c14 || text || Unknown
|-
|c15 || text || Unknown
|-
|c16 || text || Unknown
|-
|c17 || text || Unknown
|-
|c18 || text || Unknown
|-
|c19 || text || Unknown
|-
|c20 || text || Unknown
|-
|c21 || text || Unknown
|-
|c22 || text || Unknown
|-
|c23 || text || Unknown
|-
|userrating || integer ||  Rating applied by user
|-
|premiered || text ||  Date movie premiered
|}
 
==== path ====
This table stores path information.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idPath || integer || Primary Key
|-
|strPath || text || Path URL
|-
|strContent || text || Type of content (tvshows, movies, etc...)
|-
|strScraper || text || XML file of scraper used for this path
|-
|strHash || text || Hash
|-
|scanRecursive || integer || Recursive scan setting
|-
|useFolderNames || bool || User folder names setting
|-
|strSettings || text || Custom settings used by scraper
|-
|noUpdate || bool || Exclude path from library update
|-
|exclude || bool ||


|-
|dateAdded || text ||


|-
|idParentPath || integer ||
|}


=== rating ===
This table stores the ratings for TV Shows, Episodes and Movies
{|class="prettytable"
! Column Name || Data Type || Description
|-
|rating_id || integer || Primary Key
|-
|media_id || integer || Foreign key to [[Databases#episode|episode table]], [[Databases#tvshow|tv show table]], [[Databases#movie|movie table]],
|-
|media_type || text || Movies, TV Show, TV Episode
|-
|rating_type || text || default
|-
|rating || float || rating from scraper site
|-
|votes || integer || votes from scraper site
|}






==== seasons ====
This table stores the links between tv show and seasons.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idSeason || integer || Primary Key
|-
|idShow|| integer || Foreign key to [[Databases#tvshow|tvshow table]]
|-
|season || integer || Season number
|-
|name || integer || Unknown
|-
|userrating || integer || User Rating
|}


==== sets ====
{{Top}}
This table stores the id and name for movie sets. Sets are linked to movies in the movie table (idSet column).
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idSet || integer || Primary Key
|-
|strSet || text || The name of the set
|-
|strOverview || text || The description of the set
|}


==== settings ====
This table stores settings for individual files.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idFile || integer || Foreign Key to [[Databases#files|files table]]
|-
|Deinterlace || bool || Deinterlace
|-
|ViewMode|| integer || ViewMode
|-
|ZoomAmount|| float || ZoomAmount
|-
|PixelRatio|| float || PixelRatio
|-
|VerticalShift || float||
|-
|AudioStream || integer || Selected audio stream
|-
|SubtitleStream || integer || Selected subtitle stream
|-
|SubtitleDelay || float || Amount of delay for subtitles
|-
|SubtitleOn || bool || Enable subtitles
|-
|Brightness || integer || Brightness
|-
|Contrast || integer || Contrast
|-
|Gamma || integer || Gamma
|-
|VolumeAmplification || float || VolumeAmplification
|-
|AudioDelay || float || AudioDelay
|-
|OutputToAllSpeakers || bool || OutputToAllSpeakers
|-
|ResumeTime || integer || ResumeTime
|-
|Crop || bool || Crop
|-
|CropLeft || integer || CropLeft
|-
|CropRight || integer || CropRight
|-
|CropTop || integer || CropTop
|-
|CropBottom || integer || CropBottom
|-
|Sharpness || float || Sharpness
|-
|NoiseReduction || float || Noise Reduction
|-
|NonLinStretch || bool || Non Linear Stretch
|-
|PostProcess || bool || Post Processing
|-
|ScalingMethod || integer || Scaling
|-
|DeinterlaceMode || integer || Deinterlace mode
|-
|StereoMode || integer || Stereo Mode
|-
|StereoInvert || bool || Stereo Inversion
|-
|VideoStream || integer || VideoStream
|}
==== stacktimes ====
This table stores playing times for files (used for playing multi-file videos).
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idFile || integer || Foreign key to [[Databases#files|files table]]
|-
|times|| text || Times
|}
==== streamdetails ====
This table contains information regarding codecs used, aspect ratios etc
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idFile || integer || Foreign Key to [[Databases#files|files table]]
|-
|iStreamType || integer || 0 = video, 1 = audio, 2 = subtitles
|-
|strVideoCodec|| text || Video codex (xvid etc)
|-
|fVideoAspect|| real || Aspect ratio
|-
|iVideoWidth|| integer || Width of the video
|-
|iVideoHeight|| integer || Height of the video
|-
|strAudioCodec|| text || Audio codec (aac, mp3 etc)
|-
|iAudioChannels|| integer || Number of audio channels (2 for stereo, 6 for 5.1 etc)
|-
|strAudioLanguage|| text || Language of the audio track
|-
|strSubtitleLanguage|| text || Language of the subtitles
|-
|iVideoDuration|| integer ||
|-
|strStereoMode || text || Stereo Mode
|-
|strVideoLanguage|| text || Language of the Video
|}
==== studio ====
This table stores studio information.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|studio_id || integer || Primary Key
|-
|name || text || Studio Label
|}
==== studio link ====
This table links studios to movies, music videos and tv shows
{|class="prettytable"
! Column Name || Data Type || Description
|-
|studio_id || integer || Foreign key to [[Databases#studio|studio table]]
|-
|media_id || integer || Foreign key to [[Databases#movie|movie table]], [[Databases#tvshow|tv show table]], [[Databases#musicvideo|music video table]]
|-
|media_type || text || Movie, Music Video, TV Show
|}
==== tag ====
This stores tags.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|tag_id || integer || Primary Key
|-
|name || integer || Tag
|}
==== taglinks ====
This table links tags to various media.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|tag_id || integer || Foreign key to [[Databases#tag|tag table]]
|-
|media_id || integer || Foreign key to a media table
|-
|media_type || text || Media type for link
|}
==== tvshow ====
This table stores information about a television series. Information concerning the shows episodes is stored in [[Databases#episode|episode]]. To link a TV show to its episodes, use [[Databases#tvshowlinkepisode|tvshowlinkepisode]].
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idShow || integer || Primary Key
|-
|c00 || text ||  Show Title
|-
|c01 || text || Show Plot Summary
|-
|c02 || text ||  Status
|-
|c03 || text ||  Votes
|-
|c04 || text ||  Rating
|-
|c05 || text ||  First Aired
|-
|c06 || text ||  Thumbnail URL
|-
|c07 || text ||  [unknown - Spoof Thumbnail URL?]
|-
|c08 || text ||  Genre
|-
|c09 || text ||  Original Title
|-
|c10 || text ||  Episode Guide URL
|-
|c11 || text ||  Fan Art URL
|-
|c12 || text ||  SeriesId (when using thetvdb.com scraper)
|-
|c13 || text ||  Content Rating
|-
|c14 || text ||  Network
|-
|c15 || text ||  Title formatted for sorting
|-
|c16 || text ||  Not Used
|-
|c17 || text ||  Not Used
|-
|c18 || text ||  Not Used
|-
|c19 || text ||  Not Used
|-
|c20 || text ||  [unknown]
|-
|c21 || text || [unknown]
|-
|c22 || text || [unknown]
|-
|c23 || text || [unknown]
|-
|userrating || integer ||  Rating applied by user
|-
|premiered || text ||  Date tv show premiered
|}
==== tvshowlinkpath ====
This table links a TV show to its path.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idShow || integer || Foreign key to [[Databases#tvshow|tvshow table]]
|-
|idPath || integer || Foreign key to [[Databases#path|path table]]
|}
=== uniqueid ===
This table links a Movie, TV show and Episode to its the scraper site
{|class="prettytable"
! Column Name || Data Type || Description
|-
|uniqueid || integer || Primary Key
|-
|media_id || integer || Foreign key to a media table
|-
|media_type || text || Media type for link
|-
|value || text || ID at scraper site
|-
|type || text || Scraper site
|}
==== version ====
This table stores database information.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idVersion || integer || Version of database
|-
|idCompressCount || integer || Number of times database has been compressed
|}
==== writer_link ====
This table links writers stored in the actors table to movies and episodes.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|actor_id || integer || Foreign key to [[Databases#actors|actors table]]
|-
|media_id || integer || Foreign key to a media table
|-
|media_type || text || Media type for link
|}
== The View Modes Database ==
Kodi can track a user's View Mode for every path, so you could browse movies using DVD Thumbs and browse TV shows using Fanart. This database contains the last view and sorting method a user chose for each path while navigating Kodi.
The View Modes database is stored in userdata/Database/ViewModes.db.
=== Tables ===
The View Modes database uses only two tables. Most of the useful information is in [[Databases#view|view]].
==== version ====
This table stores database information.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idVersion || integer || Version of database
|-
|idCompressCount || integer || Number of times database has been compressed
|}
==== view ====
This table stores details on the saved view mode for all known paths.
{|class="prettytable"
! Column Name || Data Type || Description
|-
|idView || integer || Primary Key
|-
|window || integer || Window GUI ID
|-
|path || text || Path to trigger the view on
|-
|viewMode || integer || View Mode
|-
|sortMethod || integer || ID of sort method
|-
|sortOrder || integer || Sort order (ascending or descending)
|}
== See also ==
* [[Version table]]
* [[MySQL]]


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

Revision as of 15:53, 21 December 2020

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 its library related data (Music, Video, and Program databases). By default, the database files (*.db) are stored in the Userdata folder, specifically in userdata/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.


Using the Databases

Databases 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 and Video files on their respective pages.

The following sections detail the database structure, tables, fields and their properties.


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 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.

This query grabs all of the information for every movie in the Video Library.

select * from movie

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.

select * from movie where c07 = 2007

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.

select idMovie,idFile,c05,c07,c09,c00,c03,c02 from movie;

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:

 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;

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.


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 API


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.


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 37 13 N/A
Legend
Green Current release
Blue Future release



Links


See also




Return to top