 |
LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
Go to the documentation of this file.
81 UTIL_DB_API void RunQuery (
const QSqlDatabase& db,
const QString& plugin,
const QString& filename);
94 template<
typename T =
int>
97 const auto& lastVar = query.lastInsertId ();
98 if (lastVar.isNull ())
99 throw std::runtime_error {
"No last ID has been reported." };
101 if (!lastVar.canConvert<T> ())
103 qWarning () << Q_FUNC_INFO
106 throw std::runtime_error {
"Cannot convert last ID." };
109 return lastVar.value<T> ();
void RunQuery(const QSqlDatabase &db, const QString &pluginName, const QString &filename)
Loads the query from the given resource file and runs it.
QString LoadQuery(const QString &pluginName, const QString &filename)
Loads the query text from the given resource file.
QSqlQuery RunTextQuery(const QSqlDatabase &db, const QString &text)
Runs the given query text on the given db.
T GetLastId(const QSqlQuery &query)
Gets the last insert ID for the given query.
QString GenConnectionName(const QString &base)
Generates an unique thread-safe connection name.