QSqlDriver Class
The QSqlDriver class is an abstract base class for accessing specific SQL databases. More...
| Header: | #include <QSqlDriver> |
| qmake: | QT += sql |
| Inherits: | QObject |
Public Types
| enum | DriverFeature { Transactions, QuerySize, BLOB, Unicode, PreparedQueries, …, CancelQuery } |
| enum | IdentifierType { FieldName, TableName } |
| enum | NotificationSource { UnknownSource, SelfSource, OtherSource } |
| enum | StatementType { WhereStatement, SelectStatement, UpdateStatement, InsertStatement, DeleteStatement } |
Detailed Description
This class should not be used directly. Use QSqlDatabase instead.
If you want to create your own SQL drivers, you can subclass this class and reimplement its pure virtual functions and those virtual functions that you need. See How to Write Your Own Database Driver for more information.
See also QSqlDatabase and QSqlResult.
Member Type Documentation
enum QSqlDriver::DriverFeature
This enum contains a list of features a driver might support. Use hasFeature() to query whether a feature is supported or not.
| Constant | Value | Description |
|---|---|---|
QSqlDriver::Transactions | 0 | Whether the driver supports SQL transactions. |
QSqlDriver::QuerySize | 1 | Whether the database is capable of reporting the size of a query. Note that some databases do not support returning the size (i.e. number of rows returned) of a query, in which case QSqlQuery::size() will return -1. |
QSqlDriver::BLOB | 2 | Whether the driver supports Binary Large Object fields. |
QSqlDriver::Unicode | 3 | Whether the driver supports Unicode strings if the database server does. |
QSqlDriver::PreparedQueries | 4 | Whether the driver supports prepared query execution. |
QSqlDriver::NamedPlaceholders | 5 | Whether the driver supports the use of named placeholders. |
QSqlDriver::PositionalPlaceholders | 6 | Whether the driver supports the use of positional placeholders. |
QSqlDriver::LastInsertId | 7 | Whether the driver supports returning the Id of the last touched row. |
QSqlDriver::BatchOperations | 8 | Whether the driver supports batched operations, see QSqlQuery::execBatch() |
QSqlDriver::SimpleLocking | 9 | Whether the driver disallows a write lock on a table while other queries have a read lock on it. |
QSqlDriver::LowPrecisionNumbers | 10 | Whether the driver allows fetching numerical values with low precision. |
QSqlDriver::EventNotifications | 11 | Whether the driver supports database event notifications. |
QSqlDriver::FinishQuery | 12 | Whether the driver can do any low-level resource cleanup when QSqlQuery::finish() is called. |
QSqlDriver::MultipleResultSets | 13 | Whether the driver can access multiple result sets returned from batched statements or stored procedures. |
QSqlDriver::CancelQuery | 14 | Whether the driver allows cancelling a running query. |
More information about supported features can be found in the Qt SQL driver documentation.
See also hasFeature().
enum QSqlDriver::IdentifierType
This enum contains a list of SQL identifier types.
| Constant | Value | Description |
|---|---|---|
QSqlDriver::FieldName | 0 | A SQL field name |
QSqlDriver::TableName | 1 | A SQL table name |
enum QSqlDriver::NotificationSource
This enum contains a list of SQL notification sources.
| Constant | Value | Description |
|---|---|---|
QSqlDriver::UnknownSource | 0 | The notification source is unknown |
QSqlDriver::SelfSource | 1 | The notification source is this connection |
QSqlDriver::OtherSource | 2 | The notification source is another connection |
enum QSqlDriver::StatementType
This enum contains a list of SQL statement (or clause) types the driver can create.
| Constant | Value | Description |
|---|---|---|
QSqlDriver::WhereStatement | 0 | An SQL WHERE statement (e.g., WHERE f = 5). |
QSqlDriver::SelectStatement | 1 | An SQL SELECT statement (e.g., SELECT f FROM t). |
QSqlDriver::UpdateStatement | 2 | An SQL UPDATE statement (e.g., UPDATE TABLE t set f = 1). |
QSqlDriver::InsertStatement | 3 | An SQL INSERT statement (e.g., INSERT INTO t (f) values (1)). |
QSqlDriver::DeleteStatement | 4 | An SQL DELETE statement (e.g., DELETE FROM t). |
See also sqlStatement().