|
ImagingTools Core SDK
|
Core database engine interface for low-level SQL execution and transaction management. More...
#include <IDatabaseEngine.h>
Inherits istd::IPolymorphic.
Inherited by imtdb::CDatabaseEngineComp [virtual].
Public Member Functions | |
| virtual bool | BeginTransaction () const =0 |
| Begins a new database transaction. | |
| virtual bool | FinishTransaction () const =0 |
| Commits the current transaction. | |
| virtual bool | CancelTransaction () const =0 |
| Rolls back the current transaction. | |
| virtual QByteArray | GetDatabaseDriverId () const =0 |
| Returns the database driver identifier. | |
| virtual QSqlQuery | ExecSqlQuery (const QByteArray &queryString, QSqlError *sqlError=nullptr, bool isForwardOnly=false) const =0 |
| Executes a SQL query without parameters. | |
| virtual QSqlQuery | ExecSqlQuery (const QByteArray &queryString, const QVariantMap &bindValues, QSqlError *sqlError=nullptr, bool isForwardOnly=false) const =0 |
| Executes a parameterized SQL query with bound values. | |
| virtual QSqlQuery | ExecSqlQueryFromFile (const QString &filePath, QSqlError *sqlError=nullptr, bool isForwardOnly=false) const =0 |
| Executes SQL query from a file without parameters. | |
| virtual QSqlQuery | ExecSqlQueryFromFile (const QString &filePath, const QVariantMap &bindValues, QSqlError *sqlError=nullptr, bool isForwardOnly=false) const =0 |
| Executes parameterized SQL query from a file. | |
Core database engine interface for low-level SQL execution and transaction management.
IDatabaseEngine provides the fundamental database operations layer, handling:
This interface is database-agnostic and wraps Qt's QSqlDatabase functionality, providing a consistent API across different database backends (PostgreSQL, SQLite, etc.).
The engine supports ACID-compliant transactions:
The engine supports bound parameters to prevent SQL injection:
Definition at line 60 of file IDatabaseEngine.h.
|
pure virtual |
Begins a new database transaction.
Starts a transaction on the underlying database connection. All subsequent SQL operations will be part of this transaction until either FinishTransaction() (commit) or CancelTransaction() (rollback) is called.
|
pure virtual |
Rolls back the current transaction.
Discards all changes made during the current transaction, reverting the database to its state before BeginTransaction() was called.
|
pure virtual |
Executes a parameterized SQL query with bound values.
Executes a SQL query with placeholder parameters that are safely bound to prevent SQL injection. Placeholders use the syntax :paramName and are matched with keys in the bindValues map.
| queryString | The SQL query with placeholders (e.g., "SELECT * FROM users WHERE id = :userId") |
| bindValues | Map of placeholder names to values (e.g., {":userId", 42}) |
| sqlError | Optional pointer to receive error information if execution fails |
| isForwardOnly | If true, creates a forward-only result set (more efficient) |
|
pure virtual |
Executes a SQL query without parameters.
Executes a raw SQL query string. The query can be SELECT, INSERT, UPDATE, DELETE, or any other valid SQL statement.
| queryString | The SQL query to execute (UTF-8 encoded) |
| sqlError | Optional pointer to receive error information if execution fails |
| isForwardOnly | If true, creates a forward-only result set (more efficient for large results) |
|
pure virtual |
Executes parameterized SQL query from a file.
Reads SQL content from a file and executes it with parameter binding. Combines the benefits of external SQL files with safe parameterization.
| filePath | Path to the SQL file containing placeholders |
| bindValues | Map of placeholder names to values |
| sqlError | Optional pointer to receive error information |
| isForwardOnly | If true, creates a forward-only result set |
|
pure virtual |
Executes SQL query from a file without parameters.
Reads SQL content from a file and executes it. Useful for schema creation, migration scripts, and complex queries stored externally.
| filePath | Path to the SQL file (absolute or relative) |
| sqlError | Optional pointer to receive error information |
| isForwardOnly | If true, creates a forward-only result set |
|
pure virtual |
Commits the current transaction.
Commits all changes made during the current transaction to the database, making them permanent and visible to other connections.
|
pure virtual |
Returns the database driver identifier.