| 
    Kodi Documentation 22.0
    
   Kodi is an open source media player and entertainment hub. 
   | 
 
#include <Database.h>
  
Classes | |
| struct | DatasetFieldInfo | 
| class | DatasetLayout | 
| class | ExistsSubQuery | 
| class | Filter | 
Public Types | |
| enum class | ConnectionState { STATE_ERROR , STATE_DATABASE_NOT_FOUND , STATE_CONNECTED } | 
Public Member Functions | |
| CDatabase () | |
| virtual | ~CDatabase (void) | 
| bool | IsOpen () const | 
| virtual void | Close () | 
| bool | Compress (bool bForce=true) | 
| void | Interrupt () | 
| bool | Open (const DatabaseSettings &db) | 
| void | BeginTransaction () | 
| virtual bool | CommitTransaction () | 
| void | RollbackTransaction () | 
| void | CopyDB (const std::string &latestDb) | 
| void | DropAnalytics () | 
| std::string | PrepareSQL (std::string_view sqlFormat,...) const | 
| std::string | GetSingleValue (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const | 
| Get a single value from a table.   | |
| std::string | GetSingleValue (const std::string &query) const | 
| std::string | GetSingleValue (const std::string &query, dbiplus::Dataset &ds) const | 
| Get a single value from a query on a dataset.   | |
| int | GetSingleValueInt (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const | 
| Get a single integer value from a table.   | |
| int | GetSingleValueInt (const std::string &query) const | 
| int | GetSingleValueInt (const std::string &query, dbiplus::Dataset &ds) const | 
| Get a single integer value from a query on a dataset.   | |
| bool | DeleteValues (const std::string &strTable, const Filter &filter=Filter()) | 
| Delete values from a table.   | |
| bool | ExecuteQuery (const std::string &strQuery) | 
| Execute a query that does not return any result. Note that if BeginMultipleExecute() has been called, the query will be queued until CommitMultipleExecute() is called.   | |
| bool | ResultQuery (const std::string &strQuery) const | 
| Execute a query that returns a result.   | |
| bool | BeginMultipleExecute () | 
| Start a multiple execution queue. Any ExecuteQuery() function following this call will be queued rather than executed until CommitMultipleExecute() is performed. NOTE: Queries that rely on any queued execute query will not function as expected during this period!   | |
| bool | CommitMultipleExecute () | 
| Commit the multiple execution queue to the database. Queries are performed within a transaction, and the transaction is rolled back should any one query fail.   | |
| bool | QueueInsertQuery (const std::string &strQuery) | 
| Put an INSERT or REPLACE query in the queue.   | |
| bool | CommitInsertQueries () | 
| Commit all queries in the queue.   | |
| size_t | GetInsertQueriesCount () const | 
| Get the number of INSERT queries in the queue.   | |
| bool | QueueDeleteQuery (const std::string &strQuery) | 
| Put a DELETE query in the queue.   | |
| bool | CommitDeleteQueries () | 
| Commit all queued DELETE queries.   | |
| size_t | GetDeleteQueriesCount () const | 
| Get the number of DELETE queries in the queue.   | |
| virtual bool | GetFilter (CDbUrl &dbUrl, Filter &filter, SortDescription &sorting) | 
| virtual bool | BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl) | 
| virtual bool | BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl, SortDescription &sorting) | 
| ConnectionState | Connect (const std::string &dbName, const DatabaseSettings &db, bool create) | 
Protected Member Functions | |
| void | Split (const std::string &strFileNameAndPath, std::string &strPath, std::string &strFileName) const | 
| virtual bool | Open () | 
| bool | CreateDatabase () | 
| Create database tables and analytics as needed. Calls CreateTables() and CreateAnalytics() on child classes.   | |
| virtual void | CreateTables ()=0 | 
| virtual void | CreateAnalytics ()=0 | 
| virtual void | UpdateTables (int version) | 
| virtual int | GetMinSchemaVersion () const | 
| virtual int | GetSchemaVersion () const =0 | 
| virtual const char * | GetBaseDBName () const =0 | 
| int | GetDBVersion () | 
| bool | BuildSQL (std::string_view strQuery, const Filter &filter, std::string &strSQL) const | 
Protected Attributes | |
| bool | m_sqlite {true} | 
| whether we use sqlite (defaults to true)   | |
| std::unique_ptr< dbiplus::Database > | m_pDB | 
| std::unique_ptr< dbiplus::Dataset > | m_pDS | 
| std::unique_ptr< dbiplus::Dataset > | m_pDS2 | 
| const CProfileManager & | m_profileManager | 
Friends | |
| class | CDatabaseManager | 
      
  | 
  strong | 
| CDatabase::CDatabase | ( | ) | 
      
  | 
  virtual | 
| bool CDatabase::BeginMultipleExecute | ( | ) | 
Start a multiple execution queue. Any ExecuteQuery() function following this call will be queued rather than executed until CommitMultipleExecute() is performed. NOTE: Queries that rely on any queued execute query will not function as expected during this period!
| void CDatabase::BeginTransaction | ( | ) | 
      
  | 
  virtual | 
      
  | 
  virtual | 
      
  | 
  protected | 
      
  | 
  virtual | 
Reimplemented in PVR::CPVRDatabase, and PVR::CPVREpgDatabase.
| bool CDatabase::CommitDeleteQueries | ( | ) | 
Commit all queued DELETE queries.
| bool CDatabase::CommitInsertQueries | ( | ) | 
Commit all queries in the queue.
| bool CDatabase::CommitMultipleExecute | ( | ) | 
Commit the multiple execution queue to the database. Queries are performed within a transaction, and the transaction is rolled back should any one query fail.
      
  | 
  virtual | 
Reimplemented in CMusicDatabase, and CVideoDatabase.
| CDatabase::ConnectionState CDatabase::Connect | ( | const std::string & | dbName, | 
| const DatabaseSettings & | db, | ||
| bool | create ) | 
| void CDatabase::CopyDB | ( | const std::string & | latestDb | ) | 
      
  | 
  protectedpure virtual | 
Implemented in ADDON::CAddonDatabase, CMusicDatabase, CTextureDatabase, and CViewDatabase.
      
  | 
  protected | 
Create database tables and analytics as needed. Calls CreateTables() and CreateAnalytics() on child classes.
      
  | 
  protectedpure virtual | 
Implemented in ADDON::CAddonDatabase, CMusicDatabase, CTextureDatabase, and CViewDatabase.
Delete values from a table.
| strTable | The table to delete the values from. | 
| filter | The Filter to apply to this query. | 
| void CDatabase::DropAnalytics | ( | ) | 
| bool CDatabase::ExecuteQuery | ( | const std::string & | strQuery | ) | 
Execute a query that does not return any result. Note that if BeginMultipleExecute() has been called, the query will be queued until CommitMultipleExecute() is called.
| strQuery | The query to execute. | 
      
  | 
  protectedpure virtual | 
Implemented in ADDON::CAddonDatabase, CMusicDatabase, CTextureDatabase, CViewDatabase, PVR::CPVRDatabase, and PVR::CPVREpgDatabase.
      
  | 
  protected | 
| size_t CDatabase::GetDeleteQueriesCount | ( | ) | const | 
Get the number of DELETE queries in the queue.
      
  | 
  inlinevirtual | 
Reimplemented in CMusicDatabase, and CVideoDatabase.
| size_t CDatabase::GetInsertQueriesCount | ( | ) | const | 
Get the number of INSERT queries in the queue.
      
  | 
  inlineprotectedvirtual | 
Reimplemented in ADDON::CAddonDatabase, and CMusicDatabase.
      
  | 
  protectedpure virtual | 
Implemented in ADDON::CAddonDatabase, CMusicDatabase, CTextureDatabase, CViewDatabase, PVR::CPVRDatabase, and PVR::CPVREpgDatabase.
| std::string CDatabase::GetSingleValue | ( | const std::string & | query | ) | const | 
| std::string CDatabase::GetSingleValue | ( | const std::string & | query, | 
| dbiplus::Dataset & | ds ) const | 
Get a single value from a query on a dataset.
| query | the query in question. | 
| ds | the dataset to use for the query. | 
| std::string CDatabase::GetSingleValue | ( | const std::string & | strTable, | 
| const std::string & | strColumn, | ||
| const std::string & | strWhereClause = std::string(), | ||
| const std::string & | strOrderBy = std::string() ) const | 
Get a single value from a table.
| strTable | The table to get the value from. | 
| strColumn | The column to get. | 
| strWhereClause | If set, use this WHERE clause. | 
| strOrderBy | If set, use this ORDER BY clause. | 
| int CDatabase::GetSingleValueInt | ( | const std::string & | query | ) | const | 
| int CDatabase::GetSingleValueInt | ( | const std::string & | query, | 
| dbiplus::Dataset & | ds ) const | 
Get a single integer value from a query on a dataset.
| query | the query in question. | 
| ds | the dataset to use for the query. | 
| int CDatabase::GetSingleValueInt | ( | const std::string & | strTable, | 
| const std::string & | strColumn, | ||
| const std::string & | strWhereClause = std::string(), | ||
| const std::string & | strOrderBy = std::string() ) const | 
Get a single integer value from a table.
| strTable | The table to get the value from. | 
| strColumn | The column to get. | 
| strWhereClause | If set, use this WHERE clause. | 
| strOrderBy | If set, use this ORDER BY clause. | 
| void CDatabase::Interrupt | ( | ) | 
| bool CDatabase::IsOpen | ( | ) | const | 
      
  | 
  protectedvirtual | 
Reimplemented in ADDON::CAddonDatabase, CMusicDatabase, CTextureDatabase, CVideoDatabase, CViewDatabase, PVR::CPVRDatabase, and PVR::CPVREpgDatabase.
| bool CDatabase::Open | ( | const DatabaseSettings & | db | ) | 
| std::string CDatabase::PrepareSQL | ( | std::string_view | sqlFormat, | 
| ... ) const | 
| bool CDatabase::QueueDeleteQuery | ( | const std::string & | strQuery | ) | 
Put a DELETE query in the queue.
| strQuery | The query to queue. | 
| bool CDatabase::QueueInsertQuery | ( | const std::string & | strQuery | ) | 
Put an INSERT or REPLACE query in the queue.
| strQuery | The query to queue. | 
| bool CDatabase::ResultQuery | ( | const std::string & | strQuery | ) | const | 
Execute a query that returns a result.
| strQuery | The query to execute. | 
| void CDatabase::RollbackTransaction | ( | ) | 
      
  | 
  protected | 
Reimplemented in ADDON::CAddonDatabase, CTextureDatabase, and CViewDatabase.
      
  | 
  friend | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
whether we use sqlite (defaults to true)