QSqlDriver(3qt)
QSqlDriver π
okay bestie, so this is QSqlDriver(3qt) β the manual page for the abstract base class that lets you talk to SQL databases. it's giving "blueprint energy", not "actually-use-me energy". buckle up π
β¨ NAME β¨
QSqlDriver β Abstract base class for accessing SQL databases
π¦ SYNOPSIS π¦
#include <qsqldriver.h>
Inherits QObject.
πΈ Public Members πΈ
enum DriverFeature { Transactions, QuerySize, BLOB, Unicode, PreparedQueries, NamedPlaceholders, PositionalPlaceholders }QSqlDriver ( QObject * parent = 0, const char * name = 0 )~QSqlDriver ()bool isOpen () constbool isOpenError () constvirtual bool beginTransaction ()virtual bool commitTransaction ()virtual bool rollbackTransaction ()virtual QStringList tables ( const QString & tableType ) constvirtual QSqlIndex primaryIndex ( const QString & tableName ) constvirtual QSqlRecord record ( const QString & tableName ) constvirtual QSqlRecord record ( const QSqlQuery & query ) constvirtual QSqlRecordInfo recordInfo ( const QString & tablename ) constvirtual QSqlRecordInfo recordInfo ( const QSqlQuery & query ) constvirtual QString nullText () constvirtual QString formatValue ( const QSqlField * field, bool trimStrings = FALSE ) constQSqlError lastError () constvirtual bool hasFeature ( DriverFeature f ) const = 0virtual bool open ( const QString & db, const QString & user = QString::null, const QString & password = QString::null, const QString & host = QString::null, int port = -1 ) = 0virtual void close () = 0virtual QSqlQuery createQuery () const = 0bool open ( const QString & db, const QString & user, const QString & password, const QString & host, int port, const QString & connOpts )
π§ Protected Members π§
virtual void setOpen ( bool o )virtual void setOpenError ( bool e )virtual void setLastError ( const QSqlError & e )
π DESCRIPTION π
The QSqlDriver class is an abstract base class for accessing SQL databases.
This class should not be used directly. Use QSqlDatabase instead, bestie, fr fr. π«Ά
See also Database Classes.
π Member Type Documentation π
QSqlDriver::DriverFeature
This enum contains a list of features a driver may support. Use hasFeature() to query whether a feature is supported or not. vibe check each one β¨
QSqlDriver::Transactionsβ whether the driver supports SQL transactionsQSqlDriver::QuerySizeβ 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 caseQSqlQuery::size()will return-1QSqlDriver::BLOBβ whether the driver supports Binary Large Object fieldsQSqlDriver::Unicodeβ whether the driver supports Unicode strings if the database server doesQSqlDriver::PreparedQueriesβ whether the driver supports prepared query executionQSqlDriver::NamedPlaceholdersβ whether the driver supports usage of named placeholdersQSqlDriver::PositionalPlaceholdersβ whether the driver supports usage of positional placeholders
More information about supported features can be found in the Qt SQL driver documentation.
See also hasFeature().
π MEMBER FUNCTION DOCUMENTATION π
QSqlDriver::QSqlDriver ( QObject * parent = 0, const char * name = 0 )
Default constructor. Creates a new driver with parent parent, called name. baby driver, so cute πΈ
QSqlDriver::~QSqlDriver ()
Destroys the object and frees any allocated resources. it's giving closure, we love a clean exit β¨
bool QSqlDriver::beginTransaction () [virtual]
Protected function which derived classes can reimplement to begin a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE.
See also commitTransaction() and rollbackTransaction().
void QSqlDriver::close () [pure virtual]
Derived classes must reimplement this abstract virtual function in order to close the database connection. Return TRUE on success, FALSE on failure.
See also setOpen().
bool QSqlDriver::commitTransaction () [virtual]
Protected function which derived classes can reimplement to commit a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE.
See also beginTransaction() and rollbackTransaction().
QSqlQuery QSqlDriver::createQuery () const [pure virtual]
Creates an empty SQL result on the database. Derived classes must reimplement this function and return a QSqlQuery object appropriate for their database to the caller. no cap π₯
QString QSqlDriver::formatValue ( const QSqlField * field, bool trimStrings = FALSE ) const [virtual]
Returns a string representation of the field value for the database. This is used, for example, when constructing INSERT and UPDATE statements. iconic behaviour honestly π
The default implementation returns the value formatted as a string according to the following rules:
- If field is
NULL,nullText()is returned. - If field is character data, the value is returned enclosed in single quotation marks, which is appropriate for many SQL databases. Any embedded single-quote characters are escaped (replaced with two single-quote characters). If trimStrings is
TRUE(the default isFALSE), all trailing whitespace is trimmed from the field. - If field is date/time data, the value is formatted in ISO format and enclosed in single quotation marks. If the date/time data is invalid,
nullText()is returned. - If field is bytearray data, and the driver can edit binary fields, the value is formatted as a hexadecimal string.
- For any other field type
toString()will be called on its value and the result returned.
See also QVariant::toString().
bool QSqlDriver::hasFeature ( DriverFeature f ) const [pure virtual]
Returns TRUE if the driver supports feature f; otherwise returns FALSE.
Note that some databases need to be open() before this can be determined. π
See also DriverFeature.
bool QSqlDriver::isOpen () const
Returns TRUE if the database connection is open; otherwise returns FALSE. the vibe check of connection states π¦
bool QSqlDriver::isOpenError () const
Returns TRUE if the there was an error opening the database connection; otherwise returns FALSE. (yes, the "the there" is canon, we don't fix it, we respect it π)
QSqlError QSqlDriver::lastError () const
Returns a QSqlError object which contains information about the last error that occurred on the database.
QString QSqlDriver::nullText () const [virtual]
Returns a string representation of the NULL value for the database. This is used, for example, when constructing INSERT and UPDATE statements. The default implementation returns the string " NULL".
bool QSqlDriver::open ( const QString & db, const QString & user = QString::null, const QString & password = QString::null, const QString & host = QString::null, int port = -1 ) [pure virtual]
Derived classes must reimplement this abstract virtual function in order to open a database connection on database db, using user name user, password password, host host and port port.
The function must return TRUE on success and FALSE on failure.
See also setOpen().
bool QSqlDriver::open ( const QString & db, const QString & user, const QString & password, const QString & host, int port, const QString & connOpts )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Open a database connection on database db, using user name user, password password, host host, port port and connection options connOpts.
Returns TRUE on success and FALSE on failure.
See also setOpen().
QSqlIndex QSqlDriver::primaryIndex ( const QString & tableName ) const [virtual]
Returns the primary index for table tableName. Returns an empty QSqlIndex if the table doesn't have a primary index. The default implementation returns an empty index. no primary key? ok periodt π
QSqlRecord QSqlDriver::record ( const QString & tableName ) const [virtual]
Returns a QSqlRecord populated with the names of the fields in table tableName. If no such table exists, an empty record is returned. The default implementation returns an empty record.
QSqlRecord QSqlDriver::record ( const QSqlQuery & query ) const [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a QSqlRecord populated with the names of the fields in the SQL query. The default implementation returns an empty record.
QSqlRecordInfo QSqlDriver::recordInfo ( const QString & tablename ) const [virtual]
Returns a QSqlRecordInfo object with meta data about the table tablename. the tea on the table ββ¨
QSqlRecordInfo QSqlDriver::recordInfo ( const QSqlQuery & query ) const [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a QSqlRecordInfo object with meta data for the QSqlQuery query. Note that this overloaded function may return less information than the recordInfo() function which takes the name of a table as parameter.
bool QSqlDriver::rollbackTransaction () [virtual]
Protected function which derived classes can reimplement to rollback a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE.
See also beginTransaction() and commitTransaction().
void QSqlDriver::setLastError ( const QSqlError & e ) [virtual protected]
Protected function which allows derived classes to set the value of the last error, e, that occurred on the database.
See also lastError().
void QSqlDriver::setOpen ( bool o ) [virtual protected]
Protected function which sets the open state of the database to o. Derived classes can use this function to report the status of open().
See also open() and setOpenError().
void QSqlDriver::setOpenError ( bool e ) [virtual protected]
Protected function which sets the open error state of the database to e. Derived classes can use this function to report the status of open(). Note that if e is TRUE the open state of the database is set to closed (i.e. isOpen() returns FALSE).
See also open().
QStringList QSqlDriver::tables ( const QString & tableType ) const [virtual]
Returns a list of tables in the database. The default implementation returns an empty list.
The tableType argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum QSql::TableTypes as text. An empty string should be treated as QSql::Tables for downward compatibility. legacy but make it fashion π
See also QSql::TableType.
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
β AUTHOR β
Generated automatically from the source code.
ok bestie, that's part 1! don't go anywhere, there's more coming π
π BUGS π
okay bestie, real talk time π if you find a bug in Qt, pls pls pls report it the way they describe at http://doc.trolltech.com/bughowto.html. good bug reports help them help you, and honestly that's the whole vibe β teamwork makes the dream work π«Ά
the definitive Qt documentation is the HTML one, no cap. it lives at $QTDIR/doc/html and you can read it with Qt Assistant or literally any web browser you want. this man page? it's just a convenience for the girlies who prefer man pages π β it is NOT officially supported by Trolltech, so don't come for them if something's off here, mwah π
and if you spot actual errors in this manual page, spill the tea to qt-bugs@trolltech.com π
when you write in, pls include:
- the name of the manual page β that's
qsqldriver.3qtπ - the Qt version β that's
3.3.8β¨
that's it, that's the whole checklist, you're gonna do amazing π
<div align="center">πΈ πΈ πΈ</div>
and that's a wrap on the whole page, bestie!! π thanks for staying till the end, you're the main character fr fr π
this one's from Trolltech AS, dated 2 February 2007, and it's the man page for QSqlDriver(3qt) β go forth and talk to your databases with confidence, i believe in you ππ¦π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms