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.

ConstantValueDescription
QSqlDriver::Transactions0Whether the driver supports SQL transactions.
QSqlDriver::QuerySize1Whether 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::BLOB2Whether the driver supports Binary Large Object fields.
QSqlDriver::Unicode3Whether the driver supports Unicode strings if the database server does.
QSqlDriver::PreparedQueries4Whether the driver supports prepared query execution.
QSqlDriver::NamedPlaceholders5Whether the driver supports the use of named placeholders.
QSqlDriver::PositionalPlaceholders6Whether the driver supports the use of positional placeholders.
QSqlDriver::LastInsertId7Whether the driver supports returning the Id of the last touched row.
QSqlDriver::BatchOperations8Whether the driver supports batched operations, see QSqlQuery::execBatch()
QSqlDriver::SimpleLocking9Whether the driver disallows a write lock on a table while other queries have a read lock on it.
QSqlDriver::LowPrecisionNumbers10Whether the driver allows fetching numerical values with low precision.
QSqlDriver::EventNotifications11Whether the driver supports database event notifications.
QSqlDriver::FinishQuery12Whether the driver can do any low-level resource cleanup when QSqlQuery::finish() is called.
QSqlDriver::MultipleResultSets13Whether the driver can access multiple result sets returned from batched statements or stored procedures.
QSqlDriver::CancelQuery14Whether 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.

ConstantValueDescription
QSqlDriver::FieldName0A SQL field name
QSqlDriver::TableName1A SQL table name

enum QSqlDriver::NotificationSource

This enum contains a list of SQL notification sources.

ConstantValueDescription
QSqlDriver::UnknownSource0The notification source is unknown
QSqlDriver::SelfSource1The notification source is this connection
QSqlDriver::OtherSource2The notification source is another connection

enum QSqlDriver::StatementType

This enum contains a list of SQL statement (or clause) types the driver can create.

ConstantValueDescription
QSqlDriver::WhereStatement0An SQL WHERE statement (e.g., WHERE f = 5).
QSqlDriver::SelectStatement1An SQL SELECT statement (e.g., SELECT f FROM t).
QSqlDriver::UpdateStatement2An SQL UPDATE statement (e.g., UPDATE TABLE t set f = 1).
QSqlDriver::InsertStatement3An SQL INSERT statement (e.g., INSERT INTO t (f) values (1)).
QSqlDriver::DeleteStatement4An SQL DELETE statement (e.g., DELETE FROM t).

See also sqlStatement().