13#include <QRandomGenerator>
21 if (!
query.exec (text))
23 qDebug () <<
"unable to execute query";
25 throw std::runtime_error {
"unable to execute query" };
33 if (!
file.open (QIODevice::ReadOnly))
37 <<
file.errorString ();
38 throw std::runtime_error {
"Cannot open query file" };
41 return QString::fromUtf8 (
file.readAll ());
53 return (
base +
".%1_%2")
54 .arg (QRandomGenerator::global ()->
generate ())
55 .arg (std::bit_cast<uintptr_t> (QThread::currentThread ()));
static UTIL_DB_API void Execute(QSqlQuery &query)
Tries to execute the given query.
static UTIL_DB_API void DumpError(const QSqlError &error)
Dumps the error to the qWarning() stream.
QSqlQuery RunTextQuery(const QSqlDatabase &db, const QString &text)
Runs the given query text on the given db.
QString LoadQuery(const QString &pluginName, const QString &filename)
Loads the query text from the given resource file.
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.
Container< T > Filter(const Container< T > &c, F f)