102 UTIL_DB_API void RunQuery (
const QSqlDatabase& db,
const QString& plugin,
const QString& filename);
115 template<
typename T =
int>
118 const auto& lastVar = query.lastInsertId ();
119 if (lastVar.isNull ())
120 throw std::runtime_error {
"No last ID has been reported." };
122 if (!lastVar.canConvert<T> ())
124 qWarning () << Q_FUNC_INFO
127 throw std::runtime_error {
"Cannot convert last ID." };
130 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.
void RunTextQuery(const QSqlDatabase &db, const QString &text)
Runs the given query text on the given db.