QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCSqlHelper Namespace Reference

Lightweight SQL utilities shared across QGC components. More...

Classes

class  ScopedConnection
 RAII wrapper around QSqlDatabase::addDatabase / removeDatabase. More...
 
class  Transaction
 RAII wrapper around QSqlDatabase::transaction()/commit()/rollback(). More...
 

Functions

QString escapeLikePattern (const QString &text)
 
QString placeholders (int n)
 
void applySqlitePragmas (QSqlDatabase &db)
 
std::optional< int > userVersion (QSqlDatabase &db)
 
bool setUserVersion (QSqlDatabase &db, int v)
 

Detailed Description

Lightweight SQL utilities shared across QGC components.

Function Documentation

◆ applySqlitePragmas()

void QGCSqlHelper::applySqlitePragmas ( QSqlDatabase &  db)

Applies standard QGC pragmas: WAL journal mode, NORMAL synchronous, foreign_keys = ON.

Definition at line 33 of file QGCSqlHelper.cc.

Referenced by QGCTileCacheDatabase::connectDB(), and QGCSqlHelper::ScopedConnection::ScopedConnection().

◆ escapeLikePattern()

QString QGCSqlHelper::escapeLikePattern ( const QString &  text)

Escapes SQL LIKE wildcards (%, _, ) so the string matches literally. Use with "LIKE ? ESCAPE '\\'" in the query.

Definition at line 9 of file QGCSqlHelper.cc.

◆ placeholders()

QString QGCSqlHelper::placeholders ( int  n)

Returns "?,?,?" with n placeholders for use in IN-clauses. E.g. "DELETE FROM T WHERE id IN (" + placeholders(n) + ")".

Definition at line 18 of file QGCSqlHelper.cc.

Referenced by QGCTileCacheDatabase::createTileSet(), QGCTileCacheDatabase::deleteTileSet(), and QGCTileCacheDatabase::getTileDownloadList().

◆ setUserVersion()

bool QGCSqlHelper::setUserVersion ( QSqlDatabase &  db,
int  v 
)

Definition at line 50 of file QGCSqlHelper.cc.

◆ userVersion()

std::optional< int > QGCSqlHelper::userVersion ( QSqlDatabase &  db)

PRAGMA user_version — read/write the SQLite schema version integer. Returns std::nullopt on failure.

Definition at line 41 of file QGCSqlHelper.cc.