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_qsqldriver.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QSqlDatabase>
4#include <QSqlQuery>
5#include <QSqlDriver>
6#include <QVariant>
7
9{
10//dummy definitions
11typedef void sqlite3;
12typedef void PGconn;
13typedef void MYSQL;
16QVariant v = db.driver()->handle();
17if (v.isValid() && (qstrcmp(v.typeName(), "sqlite3*") == 0)) {
18 // v.data() returns a pointer to the handle
19 sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
20 if (handle) {
21 // ...
22 }
23}
25
27if (qstrcmp(v.typeName(), "PGconn*") == 0) {
28 PGconn *handle = *static_cast<PGconn **>(v.data());
29 if (handle) {
30 // ...
31 }
32}
33
34if (qstrcmp(v.typeName(), "MYSQL*") == 0) {
35 MYSQL *handle = *static_cast<MYSQL **>(v.data());
36 if (handle) {
37 // ...
38 }
39}
41}
The QSqlDatabase class handles a connection to a database.
static QSqlDatabase database(const QString &connectionName=QLatin1StringView(defaultConnection), bool open=true)
\threadsafe
\inmodule QtCore
Definition qvariant.h:65
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
struct pg_conn PGconn
Definition qsql_psql_p.h:26
QMimeDatabase db
[0]
void checkHandle()