HDK
|
#include <UT_SQL.h>
Protected Member Functions | |
bool | schemaItemExists (const UT_StringRef &type, const UT_StringRef &name, UT_ErrorCode *ec) const |
Friends | |
class | UT_SqlStatementHandle |
UT_SqlDatabase::UT_SqlDatabase | ( | const UT_StringRef & | filename, |
int | busy_timeout = 0 , |
||
UT_ErrorCode * | ec = nullptr |
||
) |
Open an sqlite object with the provided filename.
UT_SqlDatabase::UT_SqlDatabase | ( | ) |
UT_SqlDatabase::~UT_SqlDatabase | ( | ) |
|
delete |
UT_IntrusivePtr<UT_SqlStatementHandle> UT_SqlDatabase::cachedStatement | ( | const UT_SqlStatementHandleId & | id, |
const UT_StringRef & | sql, | ||
UT_ErrorCode * | ec = nullptr |
||
) | const |
Get a sql statement that is retrieved from the cache. If the statement is not already cached then its compiled and then cached if the compiled statement is valid.
bool UT_SqlDatabase::close | ( | UT_ErrorCode * | ec = nullptr | ) |
NO_DISCARD bool UT_SqlDatabase::columnExists | ( | const UT_StringRef & | table_name, |
const UT_StringRef & | column_name, | ||
UT_ErrorCode * | ec = nullptr |
||
) | const |
bool UT_SqlDatabase::copyTo | ( | UT_SqlDatabase & | destination, |
UT_ErrorCode * | ec = nullptr |
||
) | const |
Copy the contents of this database into the provided destination database. Return true on success and false otherwise. On failure, the error code is set in the destination database.
NO_DISCARD int UT_SqlDatabase::dataVersion | ( | UT_ErrorCode * | ec = nullptr | ) | const |
Check the database's "data_version" (see https://www.sqlite.org/pragma.html#pragma_data_version)
bool UT_SqlDatabase::endTransaction | ( | bool | commit, |
UT_ErrorCode * | ec = nullptr |
||
) |
NO_DISCARD int UT_SqlDatabase::errorCode | ( | ) | const |
NO_DISCARD UT_StringHolder UT_SqlDatabase::errorMessage | ( | ) | const |
int UT_SqlDatabase::exec | ( | const UT_StringRef & | sql, |
UT_ErrorCode * | ec = nullptr |
||
) | const |
Returns the number of rows modified, inserted or deleted.
NO_DISCARD int UT_SqlDatabase::extendedErrorCode | ( | ) | const |
UT_IntrusivePtr<UT_SqlStatementHandle> UT_SqlDatabase::findCachedStatement | ( | const UT_SqlStatementHandleId & | id | ) | const |
Find an sql handle based on its id. The sql statement must have already been added from cachedStatement(). This method is typically used when a statement has already been compiled and added to the cache but needs to be dynamically looked up some time later.
NO_DISCARD UT_StringHolder UT_SqlDatabase::getSchema | ( | UT_ErrorCode * | ec = nullptr | ) | const |
NO_DISCARD bool UT_SqlDatabase::indexExists | ( | const UT_StringRef & | name, |
UT_ErrorCode * | ec = nullptr |
||
) | const |
NO_DISCARD bool UT_SqlDatabase::isReadOnly | ( | const char * | db = "main" , |
UT_ErrorCode * | ec = nullptr |
||
) | const |
|
inline |
bool UT_SqlDatabase::open | ( | const UT_StringHolder & | filename, |
UT_ErrorCode * | ec = nullptr |
||
) |
|
delete |
|
inline |
|
protected |
bool UT_SqlDatabase::setBusyTimeout | ( | int | timeout_ms, |
UT_ErrorCode * | ec = nullptr |
||
) |
This sets a busy handler that sleeps for a specified amount of time when a table is locked. The handler will sleep multiple times until at least milliseconds of sleeping have accumulated. After the timeout the handler returns 0 which causes the step() to return kSQLITE_BUSY.
void UT_SqlDatabase::setUserVersion | ( | int | version, |
UT_ErrorCode * | ec = nullptr |
||
) | const |
bool UT_SqlDatabase::startTransaction | ( | UT_ErrorCode * | ec = nullptr | ) |
These are primarily used by UT_SqlTransaction (but can be used by any client code) and provide an abstraction that resembles nested transations. This is inspired by (and follows the same behaviour as): https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#beginTransaction()
NO_DISCARD bool UT_SqlDatabase::tableExists | ( | const UT_StringRef & | name, |
UT_ErrorCode * | ec = nullptr |
||
) | const |
Check if the specified table exists.
NO_DISCARD int UT_SqlDatabase::userVersion | ( | UT_ErrorCode * | ec = nullptr | ) | const |
Get/set the database's "user_version" (see https://www.sqlite.org/pragma.html#pragma_user_version)
NO_DISCARD bool UT_SqlDatabase::viewExists | ( | const UT_StringRef & | name, |
UT_ErrorCode * | ec = nullptr |
||
) | const |
|
friend |