![]() |
LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
General widgets and classes for databases. More...
Classes | |
class | LC::Util::BackendSelector |
A common dialog to select storage backend. More... | |
class | LC::Util::DBLock |
Provides database transaction lock. More... | |
Functions | |
QSqlQuery | LC::Util::RunTextQuery (const QSqlDatabase &db, const QString &text) |
Runs the given query text on the given db. More... | |
QString | LC::Util::LoadQuery (const QString &plugin, const QString &filename) |
Loads the query text from the given resource file. More... | |
void | LC::Util::RunQuery (const QSqlDatabase &db, const QString &plugin, const QString &filename) |
Loads the query from the given resource file and runs it. More... | |
template<typename T = int> | |
T | LC::Util::GetLastId (const QSqlQuery &query) |
Gets the last insert ID for the given query. More... | |
QString | LC::Util::GenConnectionName (const QString &base) |
Generates an unique thread-safe connection name. More... | |
General widgets and classes for databases.
UTIL_DB_API QString LC::Util::GenConnectionName | ( | const QString & | base | ) |
Generates an unique thread-safe connection name.
This function generates a connection name using the given base that is unique across all threads.
[in] | base | The identifier base to be used to generate the unique connection string. |
Definition at line 57 of file util.cpp.
Referenced by LC::Util::MakeDatabase(), and LC::Util::ConsistencyChecker::StartCheck().
T LC::Util::GetLastId | ( | const QSqlQuery & | query | ) |
Gets the last insert ID for the given query.
T | The type of the last ID. |
[in] | query | The query whose last insert ID should be retrieved. |
std::runtime_error | If no last insert ID has been reported, or if the last insert ID cannot be converted to type T. |
UTIL_DB_API QString LC::Util::LoadQuery | ( | const QString & | plugin, |
const QString & | filename | ||
) |
Loads the query text from the given resource file.
Loads the query text from the resources for the given plugin and exact filename in it.
The file name to be loaded is formed as :/${plugin}/resources/sql/${filename}.sql
.
[in] | plugin | The name of the plugin whose resources should be used. |
[in] | filename | The name of the file under ${plugin}/resources/sql . |
std::exception | If the given file cannot be opened. |
UTIL_DB_API void LC::Util::RunQuery | ( | const QSqlDatabase & | db, |
const QString & | plugin, | ||
const QString & | filename | ||
) |
Loads the query from the given resource file and runs it.
Loads the query text from the resources for the given plugin and exact filename in it and executes it on the given db.
The file name to be loaded is formed as :/${plugin}/resources/sql/${filename}.sql
.
[in] | db | The database to execute the query on. |
[in] | plugin | The name of the plugin whose resources should be used. |
[in] | filename | The name of the file under ${plugin}/resources/sql . |
std::exception | If the given file cannot be opened or if the query execution failed. |
Definition at line 50 of file util.cpp.
Referenced by LC::Util::oral::detail::SelectWrapper< T, detail::SelectBehaviour::One >::operator()().
UTIL_DB_API QSqlQuery LC::Util::RunTextQuery | ( | const QSqlDatabase & | db, |
const QString & | text | ||
) |
Runs the given query text on the given db.
Prepares and executes a QSqlQuery containing the given query text on the given db. If the query fails, an exception is thrown.
[in] | db | The database to execute the query text on. |
[in] | text | The text of the query to be executed. |
std::exception | If the query execution failed. |
Definition at line 24 of file util.cpp.
Referenced by LC::Util::MakeDatabase().