104 UTIL_DB_API void RunQuery (
const QSqlDatabase& db,
const QString& plugin,
const QString& filename);
117 template<
typename T =
int>
120 const auto& lastVar = query.lastInsertId ();
121 if (lastVar.isNull ())
122 throw std::runtime_error {
"No last ID has been reported." };
124 if (!lastVar.canConvert<T> ())
126 qWarning () << Q_FUNC_INFO
129 throw std::runtime_error {
"Cannot convert last ID." };
132 return lastVar.value<T> ();
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.
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.