Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_sql_kernel_qsqldatabase_snippet.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5QSqlDatabase::registerSqlDriver("MYDRIVER", new QSqlDriverCreator<QSqlDriver>);
11PGconn *con = PQconnectdb("host=server user=bart password=simpson dbname=springfield");
13QSqlDatabase db = QSqlDatabase::addDatabase(drv); // becomes the new default connection
15query.exec("SELECT NAME, ID FROM STAFF");
17
19unix:LIBS += -lpq
20win32:LIBS += libpqdll.lib
22
The QSqlDatabase class handles a connection to a database.
bool isValid() const
Returns true if the QSqlDatabase has a valid driver.
static QSqlDatabase addDatabase(const QString &type, const QString &connectionName=QLatin1StringView(defaultConnection))
\threadsafe
static void registerSqlDriver(const QString &name, QSqlDriverCreatorBase *creator)
[2]
static QStringList drivers()
Returns a list of all the available database drivers.
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition qsqlquery.h:24
bool exec(const QString &query)
Executes the SQL in query.
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLenum query
struct pg_conn PGconn
Definition qsql_psql_p.h:26
#define QVERIFY(statement)
Definition qtestcase.h:58