summaryrefslogtreecommitdiffstats
path: root/src/sql/doc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql/doc')
-rw-r--r--src/sql/doc/qtsql.qdocconf12
-rw-r--r--src/sql/doc/snippets/CMakeLists.txt7
-rw-r--r--src/sql/doc/snippets/code/CMakeLists.txt16
-rw-r--r--src/sql/doc/snippets/code/code.pro14
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver.cpp83
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver.qdoc287
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver_snippet.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase_snippet.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqlerror.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqlquery.cpp53
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqlquery_snippet.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_kernel_qsqlresult_snippet.cpp51
-rw-r--r--src/sql/doc/snippets/code/src_sql_models_qsqlquerymodel.cpp51
-rw-r--r--src/sql/doc/snippets/snippets.pro10
-rw-r--r--src/sql/doc/snippets/sqldatabase/CMakeLists.txt11
-rw-r--r--src/sql/doc/snippets/sqldatabase/sqldatabase.cpp57
-rw-r--r--src/sql/doc/snippets/sqldatabase/sqldatabase.pro6
-rw-r--r--src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp307
-rw-r--r--src/sql/doc/src/dontdocument.qdoc28
-rw-r--r--src/sql/doc/src/qsqldatatype-table.qdoc219
-rw-r--r--src/sql/doc/src/qt6-changes.qdoc38
-rw-r--r--src/sql/doc/src/qtsql.qdoc77
-rw-r--r--src/sql/doc/src/sql-driver.qdoc499
-rw-r--r--src/sql/doc/src/sql-programming.qdoc32
27 files changed, 820 insertions, 1395 deletions
diff --git a/src/sql/doc/qtsql.qdocconf b/src/sql/doc/qtsql.qdocconf
index 5d009e080d..9f6e1a31e0 100644
--- a/src/sql/doc/qtsql.qdocconf
+++ b/src/sql/doc/qtsql.qdocconf
@@ -15,10 +15,6 @@ qhp.QtSql.virtualFolder = qtsql
qhp.QtSql.indexTitle = Qt SQL
qhp.QtSql.indexRoot =
-qhp.QtSql.filterAttributes = qtsql $QT_VERSION qtrefdoc
-qhp.QtSql.customFilters.Qt.name = QtSql $QT_VERSION
-qhp.QtSql.customFilters.Qt.filterAttributes = qtsql $QT_VERSION
-
qhp.QtSql.subprojects = classes
qhp.QtSql.subprojects.classes.title = C++ Classes
qhp.QtSql.subprojects.classes.indexTitle = Qt SQL C++ Classes
@@ -43,3 +39,11 @@ imagedirs += images \
navigation.landingpage = "Qt SQL"
navigation.cppclassespage = "Qt SQL C++ Classes"
+
+# Highlighted examples in Data Processing & IO category
+manifestmeta.highlighted.names = \
+ "QtSql/Master Detail Example" \
+ "QtSql/SQL Browser"
+
+# Enforce zero documentation warnings
+warninglimit = 0
diff --git a/src/sql/doc/snippets/CMakeLists.txt b/src/sql/doc/snippets/CMakeLists.txt
index 911f659c26..a5c34d5688 100644
--- a/src/sql/doc/snippets/CMakeLists.txt
+++ b/src/sql/doc/snippets/CMakeLists.txt
@@ -1,4 +1,7 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
#! [cmake_use]
-find_package(Qt6 COMPONENTS Sql REQUIRED)
-target_link_libraries(mytarget Qt::Sql)
+find_package(Qt6 REQUIRED COMPONENTS Sql)
+target_link_libraries(mytarget PRIVATE Qt6::Sql)
#! [cmake_use]
diff --git a/src/sql/doc/snippets/code/CMakeLists.txt b/src/sql/doc/snippets/code/CMakeLists.txt
new file mode 100644
index 0000000000..b6899137fe
--- /dev/null
+++ b/src/sql/doc/snippets/code/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+add_library(code_snippets OBJECT
+ doc_src_sql-driver.cpp
+ src_sql_kernel_qsqldatabase.cpp
+ src_sql_kernel_qsqlerror.cpp
+ src_sql_kernel_qsqlresult.cpp
+ src_sql_kernel_qsqldriver.cpp
+ src_sql_models_qsqlquerymodel.cpp
+)
+
+target_link_libraries(code_snippets PRIVATE
+ Qt::Core
+ Qt::Sql
+)
diff --git a/src/sql/doc/snippets/code/code.pro b/src/sql/doc/snippets/code/code.pro
index 0ddb9d2ce4..d088ce94e3 100644
--- a/src/sql/doc/snippets/code/code.pro
+++ b/src/sql/doc/snippets/code/code.pro
@@ -1,11 +1,3 @@
-TEMPLATE = lib
-TARGET = code_snippets
-QT = core sql
-
-SOURCES = \
- doc_src_sql-driver.cpp \
- src_sql_kernel_qsqldatabase.cpp \
- src_sql_kernel_qsqlerror.cpp \
- src_sql_kernel_qsqlresult.cpp \
- src_sql_kernel_qsqldriver.cpp \
- src_sql_models_qsqlquerymodel.cpp
+#! [qmake_use]
+QT += sql
+#! [qmake_use]
diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp
index acfd31ee3a..efcb45c98e 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlDriver>
@@ -82,14 +35,6 @@ QSqlDatabase db;
db.setHostName("MyServer");
db.setDatabaseName("C:\\test.gdb");
//! [24]
-
-
-//! [25]
-// connect to database using the Latin-1 character set
-db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1");
-if (db.open())
- qDebug("The database connection is open.");
-//! [25]
}
void exProc()
@@ -102,10 +47,8 @@ if (q.next())
//! [26]
qDebug( \
-//! [31]
"QSqlDatabase: QMYSQL driver not loaded \
QSqlDatabase: available drivers: QMYSQL" \
-//! [31]
);
/* Commented because the following line is not compilable
@@ -135,17 +78,15 @@ while (query1.next()) {
//! [37]
}
-
-void setConnString()
+void callOutProc()
{
-//! [39]
-QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
-QString connectString = QStringLiteral(
- "DRIVER=/path/to/installation/libodbcHDB.so;"
- "SERVERNODE=hostname:port;"
- "UID=USER;"
- "PWD=PASSWORD;"
- "SCROLLABLERESULT=true");
-db.setDatabaseName(connectString);
-//! [39]
+//! [40]
+ QSqlDatabase db;
+ QSqlQuery query;
+ int i1 = 10, i2 = 0;
+ query.prepare("call qtestproc(?, ?)");
+ query.bindValue(0, i1, QSql::InOut);
+ query.bindValue(1, i2, QSql::Out);
+ query.exec();
+//! [40]
}
diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
index 1d14adcb38..896839a1d9 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
//! [0]
[...]
@@ -56,7 +9,7 @@ Database options:
-sql-<driver> ........ Enable SQL <driver> plugin. Supported drivers:
db2 ibase mysql oci odbc psql sqlite
[all auto]
- -sqlite .............. Select used sqlite3 [system/qt]
+ -sqlite .............. Select used sqlite [system/qt]
[...]
//! [0]
@@ -70,146 +23,173 @@ BEGIN
END
//! [1]
+
//! [3]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- MYSQL_PREFIX=/usr/local
-make sub-mysql
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
+cmake --build .
+cmake --install .
//! [3]
-//! [4]
-cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
-make install
-//! [4]
-
-
//! [5]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
-nmake sub-mysql
-nmake install
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
+cmake --build .
+cmake --install .
//! [5]
//! [7]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- OCI_INCDIR=/usr/include/oracle/11.2/client OCI_LIBDIR=/usr/lib/oracle/11.2/client/lib
-make sub-oci
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DOracle_INCLUDE_DIR="/usr/include/oracle/21/client64" -DOracle_LIBRARY="/usr/lib/oracle/21/client64/lib/libclntsh.<so|dylib>"
+cmake --build .
+cmake --install .
//! [7]
//! [8]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- OCI_INCDIR=c:/oracle/oci/include OCI_LIBDIR=c:/oracle/oci/lib/msvc
-nmake sub-oci
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DOracle_INCLUDE_DIR="C:\oracle\sdk\include" -DOracle_LIBRARY="C:\oracle\oci.lib"
+cmake --build .
+cmake --install .
//! [8]
//! [9]
-set PATH=%PATH%;c:\oracle\bin
+set PATH=%PATH%;C:\oracle
//! [9]
//! [11]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- ODBC_PREFIX=/usr/local/unixODBC
-make sub-odbc
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DODBC_INCLUDE_DIR="/usr/local/unixODBC/include" -DODBC_LIBRARY="/usr/local/unixODBC/lib/libodbc.<so|dylib>"
+cmake --build .
+cmake --install .
//! [11]
//! [12]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake
-nmake sub-odbc
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform>
+cmake --build .
+cmake --install .
//! [12]
//! [13]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- PSQL_INCDIR=/usr/include/pgsql
-make sub-psql
+mkdir build-psql-driver
+cd build-psql-driver
+
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers-DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DCMAKE_INCLUDE_PATH="/usr/local/pgsql/include" -DCMAKE_LIBRARY_PATH="/usr/local/pgsql/lib"
+cmake --build .
+cmake --install .
//! [13]
//! [15]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- PSQL_INCDIR=C:/psql/include PSQL_LIBDIR=C:/psql/lib/ms
-nmake sub-psql
-nmake install
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DCMAKE_INCLUDE_PATH="C:\pgsql\include" -DCMAKE_LIBRARY_PATH="C:\pgsql\lib"
+cmake --build .
+cmake --install .
//! [15]
//! [18]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- DB2_PREFIX=$DB2DIR
-make sub-db2
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DDB2_INCLUDE_DIR="/usr/local/db2/include" -DDB2_LIBRARY="/usr/local/db2/lib/libdb2.<so|dylib>"
+cmake --build .
+cmake --install .
//! [18]
//! [20]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- DB2_PREFIX="<DB2 home>/sqllib"
-nmake sub-db2
-nmake install
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DDB2_INCLUDE_DIR="C:\db2\include" -DDB2_LIBRARY="C:\db2\lib\db2.lib"
+cmake --build .
+cmake --install .
//! [20]
//! [21]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- -system-sqlite SQLITE3_PREFIX=$SQLITE
-make sub-sqlite
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DFEATURE_system_sqlite=ON -DCMAKE_INCLUDE_PATH="$SQLITE/include" -DCMAKE_LIBRARY_PATH="$SQLITE/lib"
+cmake --build .
+cmake --install .
//! [21]
//! [23]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- -system-sqlite SQLITE3_PREFIX=C:/SQLITE
-nmake sub-sqlite
-nmake install
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DFEATURE_system_sqlite=ON -DCMAKE_INCLUDE_PATH="C:\SQLITE\include" -DCMAKE_LIBRARY_PATH="C:\SQLITE\lib"
+cmake --build .
+cmake --install .
//! [23]
//! [27]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- IBASE_PREFIX=/opt/interbase
-make sub-ibase
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DInterbase_INCLUDE_DIR="/opt/interbase/include" -DInterbase_LIBRARY="/opt/interbase/lib/libgds.<so|dylib>"
+cmake --build .
+cmake --install .
//! [27]
//! [28]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- IBASE_PREFIX=/opt/interbase IBASE_LIBS=-lfbclient
-make sub-ibase
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DInterbase_INCLUDE_DIR="/opt/interbase/include" -DInterbase_LIBRARY="/opt/interbase/lib/libfbclient.<so|dylib>"
+cmake --build .
+cmake --install .
//! [28]
//! [29]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- IBASE_INCDIR=C:/interbase/include
-nmake sub-ibase
-nmake install
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DInterbase_INCLUDE_DIR="C:\interbase\include" -DInterbase_LIBRARY="C:\interbase\gds.lib"
+cmake --build .
+cmake --install .
//! [29]
//! [30]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- IBASE_INCDIR=C:/interbase/include IBASE_LIBS=-lfbclient
-nmake sub-ibase
-nmake install
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DInterbase_INCLUDE_DIR="C:\interbase\include" -DInterbase_LIBRARY="C:\interbase\lib\fbclient_ms.lib"
+cmake --build .
+cmake --install .
//! [30]
+//! [31]
+mkdir build-sqldrivers
+cd build-sqldrivers
-//! [32]
-configure OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-lclntsh -lnnz10"
-make
-//! [32]
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMimer_INCLUDE_DIR="/usr/include" -DMimer_LIBRARIES="/usr/lib/libmimer.so"
+cmake --build .
+cmake --install .
+//! [31]
-//! [33]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10"
-make sub-oci
-//! [33]
+//! [32]
+mkdir build-sqldrivers
+cd build-sqldrivers
+qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMimer_INCLUDE_DIR="C:\Program Files\Mimer SQL Experience 11.0\dev\include" -DMimer_LIBRARIES="C:\Program Files\Mimer SQL Experience 11.0\dev\lib\amd64\mimapi64.lib|C:\Program Files\Mimer SQL Experience 11.0\dev\lib\x86\mimapi32.lib"
+cmake --build .
+cmake --install .
+//! [32]
//! [35]
QSqlDatabase: QPSQL driver not loaded
@@ -236,36 +216,65 @@ QSqlRecord rec = database.record(tableString.toLower());
//! [40]
//! [41]
-C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -version
-QMake version 3.1
-Using Qt version 5.13.2 in C:/Qt5/5.13.2/mingw73_64/lib
-C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
-Info: creating stash file C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers\.qmake.stash
-
-Running configuration tests...
-Checking for DB2 (IBM)... no
-Checking for InterBase... no
-Checking for MySQL... yes
-Checking for OCI (Oracle)... no
-Checking for ODBC... yes
-Checking for PostgreSQL... no
-Done running configuration tests.
+C:\Qt\6.0.0\mingw81_64\bin\qt-cmake -G Ninja C:\Qt\6.0.0\Src\qtbase\src\plugins\sqldrivers -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.0.0\mingw81_64"
+Configure summary:
+Qt Sql Drivers:
+ DB2 (IBM) .............................. no
+ InterBase .............................. no
+ Mimer SQL .............................. yes
+ MySql .................................. yes
+ OCI (Oracle) ........................... no
+ ODBC ................................... yes
+ PostgreSQL ............................. no
+ SQLite ................................. yes
+ Using system provided SQLite ......... no
+
+-- Configuring done
+-- Generating done
+-- Build files have been written to: C:/build-qt6-sqldrivers
+//! [41]
+
+//! [42]
+C:\Qt\6.0.0\Src\configure.bat -sql-mysql -- -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
Configure summary:
+...
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
+ Mimer SQL .............................. yes
MySql .................................. yes
OCI (Oracle) ........................... no
ODBC ................................... yes
PostgreSQL ............................. no
SQLite ................................. yes
Using system provided SQLite ......... no
+...
+//! [42]
-Qt is now configured for building. Just run 'mingw32-make'.
-Once everything is built, you must run 'mingw32-make install'.
-Qt will be installed into 'C:\Qt5\5.13.2\mingw73_64'.
+//! [43]
+C:\Qt\6.0.0\Src\configure.bat -sql-mysql -- -DCMAKE_INCLUDE_PATH="C:\mysql-8.0.22-winx64\include" -DCMAKE_LIBRARY_PATH="C:\mysql-8.0.22-winx64\lib"
+Configure summary:
-Prior to reconfiguration, make sure you remove any leftovers from the previous build.
-//! [41]
+...
+Qt Sql Drivers:
+ DB2 (IBM) .............................. no
+ InterBase .............................. no
+ Mimer SQL .............................. yes
+ MySql .................................. yes
+ OCI (Oracle) ........................... no
+ ODBC ................................... yes
+ PostgreSQL ............................. no
+ SQLite ................................. yes
+ Using system provided SQLite ......... no
+...
+//! [43]
+
+//! [44]
+create procedure inout_proc (INOUT param1 INT, OUT param2 INT)
+BEGIN
+ set param1 = param1 * 2;
+ set param2 = param1 * param1;
+END
+//! [44]
diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver_snippet.cpp b/src/sql/doc/snippets/code/doc_src_sql-driver_snippet.cpp
index 7cffe58ff1..22820063e4 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver_snippet.cpp
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver_snippet.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [36]
QSqlQuery query;
QVariant v;
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp
index c7ceb847da..d892ad7567 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlDriver>
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase_snippet.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase_snippet.cpp
index a53880fee1..b321ad121b 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase_snippet.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqldatabase_snippet.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [2]
QSqlDatabase::registerSqlDriver("MYDRIVER", new QSqlDriverCreator<QSqlDriver>);
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp
index 47e8701149..3d955cbac9 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlDriver>
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqlerror.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqlerror.cpp
index d442768fe2..85a0ca6665 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqlerror.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqlerror.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlQueryModel>
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery.cpp
index 496c971621..b62d5065ce 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlDriver>
@@ -73,7 +26,7 @@ ints << 1 << 2 << 3 << 4;
q.addBindValue(ints);
QVariantList names;
-names << "Harald" << "Boris" << "Trond" << QVariant(QVariant::String);
+names << "Harald" << "Boris" << "Trond" << QVariant(QMetaType::fromType<QString>());
q.addBindValue(names);
if (!q.execBatch())
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery_snippet.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery_snippet.cpp
index d7d2a14d56..477f6ad629 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery_snippet.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqlquery_snippet.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
SELECT forename, surname FROM people;
//! [0]
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp
index 606b6d19fa..a5e135aaf3 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlDriver>
diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult_snippet.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult_snippet.cpp
index 2b1891f6c1..e17977bf54 100644
--- a/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult_snippet.cpp
+++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult_snippet.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [2]
if (qstrcmp(v.typeName(), "PGresult*") == 0) {
diff --git a/src/sql/doc/snippets/code/src_sql_models_qsqlquerymodel.cpp b/src/sql/doc/snippets/code/src_sql_models_qsqlquerymodel.cpp
index cb2bde6c7d..6577c02f40 100644
--- a/src/sql/doc/snippets/code/src_sql_models_qsqlquerymodel.cpp
+++ b/src/sql/doc/snippets/code/src_sql_models_qsqlquerymodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlDriver>
diff --git a/src/sql/doc/snippets/snippets.pro b/src/sql/doc/snippets/snippets.pro
deleted file mode 100644
index 68be4669cd..0000000000
--- a/src/sql/doc/snippets/snippets.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = subdirs
-TARGET = sqldatabase_snippets
-SUBDIRS =
-
-contains(QT_BUILD_PARTS, tests) {
- SUBDIRS += \
- code \
- sqldatabase
-}
-
diff --git a/src/sql/doc/snippets/sqldatabase/CMakeLists.txt b/src/sql/doc/snippets/sqldatabase/CMakeLists.txt
new file mode 100644
index 0000000000..5179c694d0
--- /dev/null
+++ b/src/sql/doc/snippets/sqldatabase/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+add_library(sqldatabase_snippets OBJECT
+ sqldatabase.cpp
+)
+
+target_link_libraries(sqldatabase_snippets PRIVATE
+ Qt::Core
+ Qt::Sql
+)
diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
index d58f6640a0..5702116365 100644
--- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
+++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QCoreApplication>
#include <QtSql>
@@ -203,9 +156,9 @@ void QSqlQuery_snippets()
{
// examine with named or positional binding
//! [14]
- QVariantList list = query.boundValues();
- for (int i = 0; i < list.size(); ++i)
- cout << i << ": " << list.at(i).toString().toUtf8().data() << "\n";
+ const QVariantList list = query.boundValues();
+ for (qsizetype i = 0; i < list.size(); ++i)
+ qDebug() << i << ":" << list.at(i).toString();
//! [14]
}
}
diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.pro b/src/sql/doc/snippets/sqldatabase/sqldatabase.pro
deleted file mode 100644
index b31a52996e..0000000000
--- a/src/sql/doc/snippets/sqldatabase/sqldatabase.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-TEMPLATE = lib
-TARGET = sqldatabase_snippets
-QT = core sql
-
-SOURCES = \
- sqldatabase.cpp
diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp
index 604eb97e58..48382bfee9 100644
--- a/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp
+++ b/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [16]
QSqlQueryModel *model = new QSqlQueryModel;
@@ -64,17 +17,13 @@
//! [20]
}
-//! [21]
QSqlQueryModel model;
model.setQuery("SELECT name, salary FROM employee");
int salary = model.record(4).value("salary").toInt();
-//! [21]
Q_UNUSED(salary);
{
-//! [22]
int salary = model.data(model.index(4, 1)).toInt();
-//! [22]
Q_UNUSED(salary);
}
@@ -94,7 +43,6 @@ public:
int m_specialColumnNo;
};
-//! [23]
QVariant MyModel::data(const QModelIndex &item, int role) const
{
if (item.column() == m_specialColumnNo) {
@@ -102,7 +50,6 @@ QVariant MyModel::data(const QModelIndex &item, int role) const
}
return QSqlQueryModel::data(item, role);
}
-//! [23]
void QSqlTableModel_snippets()
{
@@ -119,258 +66,8 @@ void QSqlTableModel_snippets()
view->hideColumn(0); // don't show the ID
view->show();
//! [24]
-
- {
-//! [25]
- QSqlTableModel model;
- model.setTable("employee");
- model.select();
- int salary = model.record(4).value("salary").toInt();
-//! [25]
- }
-}
-
-void sql_intro_snippets()
-{
- {
-//! [26]
- QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
- db.setHostName("bigblue");
- db.setDatabaseName("flightdb");
- db.setUserName("acarlson");
- db.setPassword("1uTbSbAs");
- bool ok = db.open();
-//! [26]
- Q_UNUSED(ok);
- }
-
- {
-//! [27]
- QSqlDatabase firstDB = QSqlDatabase::addDatabase("QMYSQL", "first");
- QSqlDatabase secondDB = QSqlDatabase::addDatabase("QMYSQL", "second");
-//! [27]
- }
-
- {
-//! [28]
- QSqlDatabase defaultDB = QSqlDatabase::database();
-//! [28] //! [29]
- QSqlDatabase firstDB = QSqlDatabase::database("first");
-//! [29] //! [30]
- QSqlDatabase secondDB = QSqlDatabase::database("second");
-//! [30]
- }
-
- {
- // SELECT1
-//! [31]
- QSqlQuery query;
- query.exec("SELECT name, salary FROM employee WHERE salary > 50000");
-//! [31]
-
-//! [32]
- while (query.next()) {
- QString name = query.value(0).toString();
- int salary = query.value(1).toInt();
- qDebug() << name << salary;
- }
-//! [32]
- }
-
- {
- // FEATURE
-//! [33]
- QSqlQuery query;
- int numRows;
- query.exec("SELECT name, salary FROM employee WHERE salary > 50000");
-
- QSqlDatabase defaultDB = QSqlDatabase::database();
- if (defaultDB.driver()->hasFeature(QSqlDriver::QuerySize)) {
- numRows = query.size();
- } else {
- // this can be very slow
- query.last();
- numRows = query.at() + 1;
- }
-//! [33]
- }
-
- {
- // INSERT1
-//! [34]
- QSqlQuery query;
- query.exec("INSERT INTO employee (id, name, salary) "
- "VALUES (1001, 'Thad Beaumont', 65000)");
-//! [34]
- }
-
- {
- // NAMED BINDING
-//! [35]
- QSqlQuery query;
- query.prepare("INSERT INTO employee (id, name, salary) "
- "VALUES (:id, :name, :salary)");
- query.bindValue(":id", 1001);
- query.bindValue(":name", "Thad Beaumont");
- query.bindValue(":salary", 65000);
- query.exec();
-//! [35]
- }
-
- {
- // POSITIONAL BINDING
-//! [36]
- QSqlQuery query;
- query.prepare("INSERT INTO employee (id, name, salary) "
- "VALUES (?, ?, ?)");
- query.addBindValue(1001);
- query.addBindValue("Thad Beaumont");
- query.addBindValue(65000);
- query.exec();
-//! [36]
- }
-
- {
- // UPDATE1
-//! [37]
- QSqlQuery query;
- query.exec("UPDATE employee SET salary = 70000 WHERE id = 1003");
-//! [37]
- }
-
- {
- // DELETE1
-//! [38]
- QSqlQuery query;
- query.exec("DELETE FROM employee WHERE id = 1007");
-//! [38]
- }
-
- {
- // TRANSACTION
-//! [39]
- QSqlDatabase::database().transaction();
- QSqlQuery query;
- query.exec("SELECT id FROM employee WHERE name = 'Torild Halvorsen'");
- if (query.next()) {
- int employeeId = query.value(0).toInt();
- query.exec("INSERT INTO project (id, name, ownerid) "
- "VALUES (201, 'Manhattan Project', "
- + QString::number(employeeId) + ')');
- }
- QSqlDatabase::database().commit();
-//! [39]
- }
-
- {
- // SQLQUERYMODEL1
-//! [40]
- QSqlQueryModel model;
- model.setQuery("SELECT * FROM employee");
-
- for (int i = 0; i < model.rowCount(); ++i) {
- int id = model.record(i).value("id").toInt();
- QString name = model.record(i).value("name").toString();
- qDebug() << id << name;
- }
-//! [40]
- }
-
- {
- // SQLTABLEMODEL1
-//! [41]
- QSqlTableModel model;
- model.setTable("employee");
- model.setFilter("salary > 50000");
- model.setSort(2, Qt::DescendingOrder);
- model.select();
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QString name = model.record(i).value("name").toString();
- int salary = model.record(i).value("salary").toInt();
- qDebug() << name << salary;
- }
-//! [41]
- }
-
- {
- // SQLTABLEMODEL2
- QSqlTableModel model;
- model.setTable("employee");
-
-//! [42]
- for (int i = 0; i < model.rowCount(); ++i) {
- QSqlRecord record = model.record(i);
- double salary = record.value("salary").toInt();
- salary *= 1.1;
- record.setValue("salary", salary);
- model.setRecord(i, record);
- }
- model.submitAll();
-//! [42]
-
- // SQLTABLEMODEL3
- int row = 1;
- int column = 2;
-//! [43]
- model.setData(model.index(row, column), 75000);
- model.submitAll();
-//! [43]
-
- // SQLTABLEMODEL4
-//! [44]
- model.insertRows(row, 1);
- model.setData(model.index(row, 0), 1013);
- model.setData(model.index(row, 1), "Peter Gordon");
- model.setData(model.index(row, 2), 68500);
- model.submitAll();
-//! [44]
-
-//! [45]
- model.removeRows(row, 5);
-//! [45] //! [46]
- model.submitAll();
-//! [46]
- }
}
-//! [47]
-class XyzResult : public QSqlResult
-{
-public:
- XyzResult(const QSqlDriver *driver)
- : QSqlResult(driver) {}
- ~XyzResult() {}
-
-protected:
- QVariant data(int /* index */) override { return QVariant(); }
- bool isNull(int /* index */) override { return false; }
- bool reset(const QString & /* query */) override { return false; }
- bool fetch(int /* index */) override { return false; }
- bool fetchFirst() override { return false; }
- bool fetchLast() override { return false; }
- int size() override { return 0; }
- int numRowsAffected() override { return 0; }
- QSqlRecord record() const override { return QSqlRecord(); }
-};
-//! [47]
-
-//! [48]
-class XyzDriver : public QSqlDriver
-{
-public:
- XyzDriver() {}
- ~XyzDriver() {}
-
- bool hasFeature(DriverFeature /* feature */) const override { return false; }
- bool open(const QString & /* db */, const QString & /* user */,
- const QString & /* password */, const QString & /* host */,
- int /* port */, const QString & /* options */) override
- { return false; }
- void close() {}
- QSqlResult *createResult() const override { return new XyzResult(this); }
-};
-//! [48]
int main(int argc, char **argv)
{
diff --git a/src/sql/doc/src/dontdocument.qdoc b/src/sql/doc/src/dontdocument.qdoc
index 0193ace4b4..3601a9841a 100644
--- a/src/sql/doc/src/dontdocument.qdoc
+++ b/src/sql/doc/src/dontdocument.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\dontdocument (QTypeInfo)
diff --git a/src/sql/doc/src/qsqldatatype-table.qdoc b/src/sql/doc/src/qsqldatatype-table.qdoc
index 1c5ab741c9..77aa56d21a 100644
--- a/src/sql/doc/src/qsqldatatype-table.qdoc
+++ b/src/sql/doc/src/qsqldatatype-table.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page sql-types.html
@@ -64,15 +40,15 @@
\row
\li REAL
\li 32-bit Single-precision floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li DOUBLE PRECISION
\li 64-bit Double-precision floating point
- \li By default mapping to QString
+ \li Mapped to QString for high precision doubles, otherwise qreal
\row
\li FLOAT
\li 64-bit Double-precision floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li CHAR
\li Fixed-length, null-terminated character string
@@ -139,19 +115,19 @@
\row
\li REAL FLOAT
\li 32-bit floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li FLOAT
\li 64-bit floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li DOUBLE
\li 64-bit floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li DOUBLE PRECISION
\li 64-bit Double-precision floating point
- \li By default mapping to QString
+ \li Mapped to QString for high precision doubles, otherwise qreal
\row
\li VARCHAR STRING
\li Character string, Unicode
@@ -212,11 +188,11 @@
\row
\li FLOAT
\li 32-bit Floating Point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li DOUBLE
\li 64-bit Floating Point
- \li By default mapping to QString
+ \li Mapped to QString for high precision doubles, otherwise qreal
\row
\li CHAR
\li Character string
@@ -285,7 +261,7 @@
\row
\li NUMBER
\li FLOAT, DOUBLE, PRECISIONc REAL
- \li By default mapping to QString
+ \li Mapped to QString for high precision doubles, otherwise qreal
\row
\li NUMBER(38)
\li INTEGER INT SMALLINT
@@ -293,7 +269,7 @@
\row
\li NUMBER(p,s)
\li NUMERIC(p,s) DECIMAL(p,s)a
- \li By default mapping to QString
+ \li Mapped to QString
\row
\li NVARCHAR2(n)
\li Character string (NATIONAL CHARACTER VARYING(n) NATIONAL
@@ -353,15 +329,15 @@
\row
\li REAL
\li 32-bit Single-precision floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li FLOAT
\li 64-bit Double floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li DOUBLE
\li 64-bit Double floating point
- \li By default mapping to QString
+ \li Mapped to QString for high precision doubles, otherwise qreal
\row
\li CHAR
\li Character string
@@ -418,19 +394,19 @@
\row
\li REAL
\li 32-bit variable-precision floating point
- \li By default mapping to QString
+ \li typedef qreal
\row
\li DOUBLE PRECISION
\li 64-bit variable-precision floating point
- \li By default mapping to QString
+ \li Mapped to QString for high precision doubles, otherwise qreal
\row
\li DECIMAL VARIABLE
\li user-specified precision, exact
- \li Mapped to QString
+ \li typedef qreal
\row
\li NUMERIC VARIABLE
\li user-specified precision, exact
- \li Mapped to QString
+ \li typedef qreal
\row
\li VARCHAR
\li variable-length character string
@@ -488,7 +464,7 @@
\row
\li REAL
\li 64-bit floating point value.
- \li By default mapping to QString
+ \li typedef qreal
\row
\li TEXT
\li Character string (UTF-8, UTF-16BE or UTF-16-LE).
@@ -502,4 +478,157 @@
\li The value is a BLOB of data, stored exactly as it was input.
\li Mapped to QByteArray
\endtable
+
+ \section2 Mimer SQL Data Types
+
+ \table 90%
+ \header
+ \li Mimer SQL type
+ \li SQL type description
+ \li Recommended input (C++ or Qt data type)
+ \row
+ \li SMALLINT
+ \li 16-bit signed integer
+ \li typedef qint16
+ \row
+ \li INTEGER
+ \li 32-bit signed integer
+ \li typedef qint32
+ \row
+ \li INTEGER(n)
+ \li Integer with up to 45 digits precision
+ \li Mapped to QString
+ \row
+ \li BIGINT
+ \li 64-bit signed integer
+ \li typedef qint64
+ \row
+ \li REAL
+ \li 32-bit Single-precision IEEE floating point
+ \li typedef float
+ \row
+ \li DOUBLE PRECISION
+ \li 64-bit Double-precision IEEE floating point
+ \li Mapped to QString for high precision doubles, otherwise qreal
+ \row
+ \li FLOAT
+ \li 64-bit Double-precision IEEE floating point
+ \li Mapped to QString for high precision doubles, otherwise qreal
+ \row
+ \li FLOAT(n)
+ \li Floating point with up to 45 digits precision
+ \li Mapped to QString
+ \row
+ \li DECIMAL(p,s)
+ \li Decimal with up to 45 digits precision and scale
+ \li Mapped to QString
+ \row
+ \li CHAR
+ \li Fixed-length character Latin-1 string (CHAR or character)
+ \li Mapped to QString
+ \row
+ \li VARCHAR
+ \li Variable length Latin-1 string (VARCHAR or CHARACTER VARYING)
+ \li Mapped to QString
+ \row
+ \li NCHAR
+ \li Fixed-length Unicode string (NCHAR or NATIONAL CHARACTER)
+ \li Mapped to QString
+ \row
+ \li NVARCHAR
+ \li Variable length Unicode string (NVARCHAR or NATIONAL CHARACTER VARYING)
+ \li Mapped to QString
+ \row
+ \li BINARY
+ \li Fixed length binary data
+ \li Mapped to QByteArray
+ \row
+ \li VARBINARY
+ \li Variable length binary data (VARBINARY or BINARY VARYING)
+ \li Mapped to QByteArray
+ \row
+ \li BLOB
+ \li Binary large object (BLOB or BINARY LARGE OBJECT)
+ \li Mapped to QByteArray
+ \row
+ \li CLOB
+ \li Latin-1 character large object (CLOB or CHARACTER LARGE OBJECT)
+ \li Mapped to QString
+ \row
+ \li NCLOB
+ \li Unicode character large object (NCLOB or NATIONAL CHARACTER LARGE OBJECT)
+ \li Mapped to QString
+ \row
+ \li DATE
+ \li Date consisting of year, month, and day
+ \li Mapped to QDate
+ \row
+ \li TIME
+ \li Time consisting of hours, minute, seconds with optional fractional seconds
+ \li Mapped to QTime
+ \row
+ \li TIMESTAMP
+ \li Date and time with optional fractional seconds
+ \li Mapped to QDateTime
+ \row
+ \li BUILTIN.UUID
+ \li Universally unique identifier
+ \li Mapped to QUuid
+ \row
+ \li BOOLEAN
+ \li Boolean
+ \li bool
+ \row
+ \li INTERVAL YEAR(7)
+ \li Year, format '±yyyyyyy' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL YEAR(7) TO MONTH
+ \li Year to month, format '±yyyyyyy-mm' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL MONTH(7)
+ \li Month, format '±mmmmmmm' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL DAY(7)
+ \li Day, format '±ddddddd' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL DAY(7) TO HOUR
+ \li Day to hour, format '±ddddddd hh' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL DAY(7) TO MINUTE
+ \li Day to minute, format '±ddddddd hh:mm' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL DAY(7) TO SECOND(9)
+ \li Day to second, format '±ddddddd hh:mm:ss[.fffffffff]' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL HOUR(8)
+ \li Hour, format '±hhhhhhhh' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL HOUR(8) TO MINUTE
+ \li Hour to minute, format '±hhhhhhhh:mm' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL HOUR(8) TO SECOND(9)
+ \li Hour to second, format '±hhhhhhhh:mm:ss[.fffffffff]' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL MINUTE(10)
+ \li Minute, format '±mmmmmmmmmm' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL MINUTE(10) TO SECOND(9)
+ \li Minute to second, format '±mmmmmmmmmm:ss[.fffffffff]' (max precision)
+ \li Mapped to QString
+ \row
+ \li INTERVAL SECOND(12,9)
+ \li Second, format '±ssssssssssss[.fffffffff]' (max precision)
+ \li Mapped to QString
+ \endtable
*/
diff --git a/src/sql/doc/src/qt6-changes.qdoc b/src/sql/doc/src/qt6-changes.qdoc
index 7f03b57da5..28c4664fdd 100644
--- a/src/sql/doc/src/qt6-changes.qdoc
+++ b/src/sql/doc/src/qt6-changes.qdoc
@@ -1,35 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtsql-changes-qt6.html
- \title Porting to Qt 6 - Qt Sql
- \ingroup porting-guides-5-to-6
- \brief Migrate Qt Sql to Qt 6.
+ \title Changes to Qt SQL
+ \ingroup changes-qt-5-to-6
+ \brief The return type for boundValues() has been changed in QSqlQuery class.
Qt 6 is a result of the conscious effort to make the framework more
efficient and easy to use.
@@ -38,10 +14,10 @@
APIs in each release. But some changes were inevitable in an effort to
make Qt a better framework.
- In this topic we summarize those changes in Qt Sql, and provide guidance
+ In this topic we summarize those changes in Qt SQL, and provide guidance
to handle them.
- \section1 QSqlQuery
+ \section1 The QSqlQuery class
\section2 boundValues() Signature
diff --git a/src/sql/doc/src/qtsql.qdoc b/src/sql/doc/src/qtsql.qdoc
index 19d90d930b..78acaf1fd0 100644
--- a/src/sql/doc/src/qtsql.qdoc
+++ b/src/sql/doc/src/qtsql.qdoc
@@ -1,37 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtsql-index.html
\title Qt SQL
\brief Provides a driver layer, SQL API layer, and a user
interface layer for SQL databases
- Qt SQL is an essential module which provides support for SQL databases. Qt
- SQL's APIs are divided into different layers:
+ The Qt SQL module provides support for SQL databases. Qt SQL's APIs are
+ divided into different layers:
\list
\li Driver layer
@@ -41,16 +17,38 @@
The \l{SQL Programming} guide contains information about development using
Qt SQL.
- \include module-use.qdocinc using qt module
- \snippet snippets/CMakeLists.txt cmake_use
+ \section1 Using the Module
- See also the \l[QtDoc]{Build with CMake} overview.
+ \include {module-use.qdocinc} {using the c++ api}
- \include module-use.qdocinc building with qmake
- \snippet snippets/snippets.pro qmake_use
+ \section2 Building with CMake
+
+ \include {module-use.qdocinc} {building with cmake} {Sql}
+
+ \section2 Building with qmake
+
+ \include {module-use.qdocinc} {building_with_qmake} {sql}
+
+ \section1 Articles and Guides
+
+ \list
+ \li \l {SQL Programming} {Qt SQL Programming Guide}
+ \endlist
+
+ \section1 Examples
+
+ \list
+ \li \l {SQL Examples}
+ \endlist
+
+ \section1 Reference
+
+ \list
+ \li \l {Qt SQL C++ Classes} {C++ Classes}
+ \endlist
\section1 Module Evolution
- \l{Porting to Qt 6 - Qt SQL} lists important changes in the module API
+ \l{Changes to Qt SQL} lists important changes in the module API
and functionality that were done for the Qt 6 series of Qt.
\section1 Licenses and Attributions
@@ -65,14 +63,6 @@
modules under following permissive licenses:
\generatelist{groupsbymodule attributions-qtsql}
-
- \section1 Related Information
-
- These are links to the API reference materials and related pages.
- \list
- \li \l{Qt SQL C++ Classes}{C++ Classes}
- \li \l{SQL Examples}
- \endlist
*/
/*!
@@ -84,6 +74,5 @@
\brief Provides a driver layer, SQL API layer, and a user
interface layer for SQL databases.
- See the \l{Qt SQL} page and the \l{SQL Programming} guide for further
- information about using this module in your application.
+ The \l{Qt SQL} page contains information about how to use the module.
*/
diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc
index e6b7c1fbf2..4cc5b0d050 100644
--- a/src/sql/doc/src/sql-driver.qdoc
+++ b/src/sql/doc/src/sql-driver.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page sql-driver.html
@@ -47,7 +23,7 @@
\table
\header \li Driver name \li DBMS
\row \li \l{#QDB2}{QDB2} \li IBM DB2 (version 7.1 and above)
- \row \li \l{#QIBASE}{QIBASE} \li Borland InterBase (version 7.0 and above) or Firebird (version 3.0 and above)
+ \row \li \l{#QIBASE}{QIBASE} \li Borland InterBase / Firebird
\row \li \l{#QMYSQL}{QMYSQL / MARIADB} \li MySQL or MariaDB (version 5.6 and above)
\row \li \l{#QOCI}{QOCI} \li Oracle Call Interface Driver (version 12.1 and above)
\row \li \l{#QODBC}{QODBC}
@@ -55,6 +31,7 @@
ODBC-compliant databases
\row \li \l{#QPSQL}{QPSQL} \li PostgreSQL (versions 7.3 and above)
\row \li \l{#QSQLITE}{QSQLITE} \li SQLite version 3
+ \row \li \l{#QMIMER}{QMIMER} \li Mimer SQL (version 11 and above)
\endtable
SQLite is the in-process database system with the best test coverage
@@ -63,7 +40,7 @@
Linux. The completeness of the support for other systems depends on the
availability and quality of client libraries.
- \b{Note:} To build a driver plugin you need to have the appropriate
+ \note To build a driver plugin you need to have the appropriate
client library for your Database Management System (DBMS). This provides
access to the API exposed by the DBMS, and is typically shipped with it.
Most installation programs also allow you to install "development
@@ -89,42 +66,53 @@
The \c configure script cannot detect the necessary libraries
and include files if they are not in the standard paths, so it
- may be necessary to specify these paths using the \c *_INCDIR=,
- \c *_LIBDIR=, or \c *_PREFIX= command-line options. For example,
- if your MySQL files are installed in \c /usr/local/mysql (or in
- \c{C:/Program Files/MySQL/MySQL Connector C 6.1} on Windows), then pass the
- following parameter to configure: \c MYSQL_PREFIX=/usr/local/mysql
- (or \c{MYSQL_PREFIX="C:/Program Files/MySQL/MySQL Connector C 6.1"} for Windows).
+ may be necessary to specify these paths using either
+ driver-specific include and library path variables or \c CMAKE_INCLUDE_PATH
+ and \c CMAKE_LIBRARY_PATH. For example, if your MySQL files are
+ installed in \c{C:\mysql-connector-c-6.1.11-winx64} on Windows, then pass
+ the following parameter to double-dash part of configure line:
+ \snippet code/doc_src_sql-driver.qdoc 42
+ When you configure drivers in the manner described above, CMake skips any
+ dependency checks and uses the provided paths as is. This is especially
+ useful if the package provides its own set of system libraries that
+ should not be recognized by the build routine.
+
+ In some cases it's more convenient to use \c CMAKE_INCLUDE_PATH
+ and \c CMAKE_LIBRARY_PATH variables to locate required libraries.
+ You should prefer this method if module needs to set properties
+ for the provided target libraries (e.g. this is required for PostgreSQL
+ and SQLite).
+ For example, you can do this as follows, to locate MySQL:
+ \snippet code/doc_src_sql-driver.qdoc 43
+
The particulars for each driver are explained below.
- \note If something goes wrong and you want qmake to recheck your
- available drivers, you must remove \e{config.cache} in
- \e{<QTDIR>/qtbase/src/plugins/sqldrivers} - otherwise qmake will not
- search for the available drivers again. If you encounter an error during
- the qmake stage, open \e{config.log} to see what went wrong.
+ \note If something goes wrong and you want CMake to recheck your
+ available drivers, you might need to remove \e{CMakeCache.txt} from the build
+ directory.
\target DriverStandalone
\section2 Compile only a specific sql driver
- A typical qmake run (in this case to configure for MySQL) looks like this:
+ A typical \c qt-cmake run (in this case to configure for MySQL) looks like this:
\snippet code/doc_src_sql-driver.qdoc 41
\note As mentioned in \l{#DriverWithQt}{Compile Qt with a specific driver},
- take a look at \e{config.log} if the driver could not be found and
- start over by removing \e{config.cache}.
+ if the driver could not be found or is not enabled, start over by removing
+ \e{CMakeCache.txt}.
Due to the practicalities of dealing with external dependencies,
- only the SQLite3 plugin is shipped with binary builds of Qt.
+ only the SQLite plugin is shipped with binary builds of Qt.
+ Binary builds of Qt for Windows also include the ODBC plugin.
To be able to add additional drivers to the Qt installation
without re-building all of Qt, it is possible to configure
and build the \c qtbase/src/plugins/sqldrivers directory outside
of a full Qt build directory. Note that it is not possible to
\e configure each driver separately, only all of them at once.
Drivers can be \e built separately, though.
- If the Qt build is configured with \c{-prefix}, it is necessary to
- install the plugins after building them, too. For example:
- \snippet code/doc_src_sql-driver.qdoc 4
+ \note You need to specify \c{CMAKE_INSTALL_PREFIX}, if you want to install
+ plugins after the build is finished.
\section1 Driver Specifics
@@ -139,7 +127,7 @@
\section3 QMYSQL Stored Procedure Support
- MySQL 5 has stored procedure support at the SQL level, but no
+ MySQL has stored procedure support at the SQL level, but no
API to control IN, OUT, and INOUT parameters. Therefore, parameters
have to be set and read using SQL commands instead of QSqlQuery::bindValue().
@@ -151,7 +139,7 @@
\snippet code/doc_src_sql-driver.cpp 2
- \b{Note:} \c{@outval1} and \c{@outval2} are variables local to the current
+ \note \c{@outval1} and \c{@outval2} are variables local to the current
connection and will not be affected by queries sent from another host
or connection.
@@ -163,29 +151,119 @@
To use the embedded MySQL server, simply link the Qt plugin to \c
libmysqld instead of \c libmysqlclient. This can be done by adding
- \c MYSQL_LIBS=-lmysqld to the configure command line.
+ \c{-DMySQL_LIBRARY=<path/to/mysqld/>libmysqld.<so|lib|dylib>} to the configure command line.
Please refer to the MySQL documentation, chapter "libmysqld, the Embedded
MySQL Server Library" for more information about the MySQL embedded server.
+ \section3 Connection options
+ The Qt MySQL/MariaDB plugin honors the following connection options:
+ \table
+ \header \li Attribute \li Possible value
+ \row
+ \li CLIENT_COMPRESS
+ \li If set, switches to compressed protocol after successful authentication
+ \row
+ \li CLIENT_FOUND_ROWS
+ \li If set, send found rows instead of affected rows
+ \row
+ \li CLIENT_IGNORE_SPACE
+ \li If set, ignore spaces before '('
+ \row
+ \li CLIENT_NO_SCHEMA
+ \li If set, don't allow database.table.column
+ \row
+ \li CLIENT_INTERACTIVE
+ \li If set, client is treated as interactive
+ \row
+ \li MYSQL_OPT_PROTOCOL
+ \li explicitly specify the protocol to use:\br
+ MYSQL_PROTOCOL_TCP: use tcp connection (ip/hostname specified through setHostname())
+ MYSQL_PROTOCOL_SOCKET: connect through a socket specified in UNIX_SOCKET
+ MYSQL_PROTOCOL_PIPE: connect through a named pipe specified in UNIX_SOCKET
+ MYSQL_PROTOCOL_MEMORY: connect through shared memory specified in MYSQL_SHARED_MEMORY_BASE_NAME
+ \row
+ \li UNIX_SOCKET
+ \li Specifies the socket or named pipe to use, even it's called UNIX_SOCKET it
+ can also be used on windows
+ \row
+ \li MYSQL_SHARED_MEMORY_BASE_NAME
+ \li Specified the shared memory segment name to use
+ \row
+ \li MYSQL_OPT_RECONNECT
+ \li TRUE or 1: Automatically reconnect after connection loss\br
+ FALSE or 0: No automatic reconnect after connection loss (default)\br
+ See \l {https://dev.mysql.com/doc/c-api/8.0/en/c-api-auto-reconnect.html}
+ {Automatic Reconnection Control}
+ \row
+ \li MYSQL_OPT_CONNECT_TIMEOUT
+ \li The connect timeout in seconds
+ \row
+ \li MYSQL_OPT_READ_TIMEOUT
+ \li The timeout in seconds for each attempt to read from the server
+ \row
+ \li MYSQL_OPT_WRITE_TIMEOUT
+ \li The timeout in seconds for each attempt to write to the server
+ \row
+ \li MYSQL_OPT_LOCAL_INFILE
+ \li Set to 1 to enable the support for local
+ \l {https://dev.mysql.com/doc/refman/8.0/en/load-data.html} {LOAD_DATA},
+ disabled if not set or 0
+ \row
+ \li MYSQL_OPT_SSL_MODE
+ \li The security state to use for the connection to the server: SSL_MODE_DISABLED,
+ SSL_MODE_PREFERRED, SSL_MODE_REQUIRED, SSL_MODE_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY.
+ \row
+ \li MYSQL_OPT_TLS_VERSION
+ \li A list of protocols the client permits for encrypted connections. The value can be
+ a combination of 'TLSv1' ,' TLSv1.1', 'TLSv1.2' or 'TLSv1.3' depending on the used \l
+ {https://dev.mysql.com/doc/refman/8.0/en/encrypted-connection-protocols-ciphers.html#encrypted-connection-protocol-configuration}
+ {MySQL server} version.
+ \row
+ \li MYSQL_OPT_SSL_KEY / SSL_KEY (deprecated)
+ \li The path name of the client private key file
+ \row
+ \li MYSQL_OPT_SSL_CERT / SSL_CERT (deprecated)
+ \li The path name of the client public key certificate file
+ \row
+ \li MYSQL_OPT_SSL_CA / SSL_CA (deprecated)
+ \li The path name of the Certificate Authority (CA) certificate file
+ \row
+ \li MYSQL_OPT_SSL_CAPATH / SSL_CAPATH (deprecated)
+ \li The path name of the directory that contains trusted SSL CA certificate files
+ \row
+ \li MYSQL_OPT_SSL_CIPHER / SSL_CIPHER (deprecated)
+ \li The list of permissible ciphers for SSL encryption
+ \row
+ \li MYSQL_OPT_SSL_CRL
+ \li The path name of the file containing certificate revocation lists
+ \row
+ \li MYSQL_OPT_SSL_CRLPATH
+ \li The path name of the directory that contains files containing certificate revocation lists
+ \endtable
+ For more detailed information about the connect options please refer
+ to the \l {https://dev.mysql.com/doc/c-api/8.0/en/mysql-options.html}
+ {mysql_options()} MySQL documentation.
+
+
\section3 How to Build the QMYSQL Plugin on Unix and \macos
You need the MySQL / MariaDB header files, as well as the shared library
- \c{libmysqlclient.so} / \c{libmariadb.so}. Depending on your Linux distribution,
+ \c{libmysqlclient.<so|dylib>} / \c{libmariadb.<so|dylib>}. Depending on your Linux distribution,
you may need to install a package which is usually called "mysql-devel"
or "mariadb-devel".
- Tell \l qmake where to find the MySQL / MariaDB header files and shared
+ Tell \c qt-cmake where to find the MySQL / MariaDB header files and shared
libraries (here it is assumed that MySQL / MariaDB is installed in
- \c{/usr/local}) and run \c{make}:
+ \c{/usr/local}) and build:
\snippet code/doc_src_sql-driver.qdoc 3
\section3 How to Build the QMYSQL Plugin on Windows
You need to get the MySQL installation files (e.g.
- \l {https://dev.mysql.com/downloads/installer/}{mysql-installer-web-community-8.0.18.0.msi}) or
- \l {https://downloads.mariadb.org/connector-c/3.1.5/}{mariadb-connector-c-3.1.5-win64.msi}.
+ \l {https://dev.mysql.com/downloads/installer/}{MySQL web installer} or
+ \l {https://downloads.mariadb.com/Connectors/c/}{MariaDB C Connector}).
Run the installer,
select custom installation and install the MySQL C Connector
which matches your Qt installation (x86 or x64).
@@ -208,13 +286,10 @@
\l{https://downloads.mariadb.org/connector-c/}{MariaDB C Connector}.
Build the plugin as follows (here it is assumed that \c{<MySQL dir>} is
- \c{C:/Program Files/MySQL/MySQL Connector C 6.1}):
+ \c{C:\mysql-8.0.22-winx64}):
\snippet code/doc_src_sql-driver.qdoc 5
- If you are not using a Microsoft compiler, replace \c nmake with \c
- mingw32-make above.
-
When you distribute your application, remember to include \e libmysql.dll / \e libmariadb.dll
in your installation package. It must be placed in the same folder
as the application executable. \e libmysql.dll additionally needs the
@@ -253,33 +328,50 @@
BLOBs are bound to placeholders or QSqlTableModel, which uses a prepared
query to do this internally.
+ \section3 Connection options
+ The Qt OCI plugin honors the following connection options:
+ \table
+ \header \li Attribute \li Possible value
+ \row
+ \li OCI_ATTR_PREFETCH_ROWS
+ \li Sets the OCI attribute
+ \l {https://docs.oracle.com/database/121/LNOCI/oci04sql.htm#LNOCI16355}
+ {OCI_ATTR_PREFETCH_ROWS} to the specified value
+ \row
+ \li OCI_ATTR_PREFETCH_MEMORY
+ \li Sets the OCI attribute
+ \l {https://docs.oracle.com/database/121/LNOCI/oci04sql.htm#LNOCI16355}
+ {OCI_ATTR_PREFETCH_MEMORY} to the specified value
+ \row
+ \li OCI_AUTH_MODE
+ \li OCI_SYSDBA: authenticate for SYSDBA access\br
+ OCI_SYSOPER: authenticate for SYSOPER access\br
+ OCI_DEFAULT: authenticate with normal access\br
+ see \l {https://docs.oracle.com/cd/B10500_01/appdev.920/a96584/oci15r13.htm}
+ {OCISessionBegin} for more information about the access modes
+ \endtable
+
\section3 How to Build the OCI Plugin on Unix and \macos
- All you need is the "Instant Client Package - Basic" and "Instant Client
+ All you need is the " - Basic" and "Instant Client
Package - SDK".
Oracle library files required to build the driver:
\list
- \li \c libclntsh.so (all versions)
+ \li \c libclntsh.<so|dylib> (all versions)
\endlist
- Tell \c qmake where to find the Oracle header files and shared
- libraries and run make:
+ Tell \c qt-cmake where to find the Oracle header files and shared
+ libraries and build.
We assume that you installed the RPM packages of the Instant Client Package SDK
(you need to adjust the version number accordingly):
\snippet code/doc_src_sql-driver.qdoc 7
- \b{Note:} If you are using the Oracle Instant Client package,
+ \note If you are using the Oracle Instant Client package,
you will need to set LD_LIBRARY_PATH when building the OCI SQL plugin,
- and when running an application that uses the OCI SQL plugin. You can
- avoid this requirement by setting RPATH, and listing all of the
- libraries to link to. Here is an example:
- \snippet code/doc_src_sql-driver.qdoc 32
-
- If you wish to build the OCI plugin manually with this method, the procedure looks like this:
- \snippet code/doc_src_sql-driver.qdoc 33
+ and when running an application that uses the OCI SQL plugin.
\section3 How to Build the OCI Plugin on Windows
@@ -289,13 +381,10 @@
the "Call Interface (OCI)" option if it is available.
Build the plugin as follows (here it is assumed that Oracle Client is
- installed in \c{C:\oracle}):
+ installed in \c{C:\oracle} and SDK is installed in \c{C:\oracle\sdk}):
\snippet code/doc_src_sql-driver.qdoc 8
- If you are not using a Microsoft compiler, replace \c nmake with \c
- mingw32-make in the line above.
-
When you run your application, you will also need to add the \c oci.dll
path to your \c PATH environment variable:
@@ -311,19 +400,24 @@
driver manager that is installed on your system. The QODBC plugin
then allows you to use these data sources in your Qt applications.
- \b{Note:} You should use the native driver, if it is available, instead
+ \note You should use the native driver, if it is available, instead
of the ODBC driver. ODBC support can be used as a fallback for compliant
databases if no native driver is available.
- On Windows, an ODBC driver manager should be installed by default.
+ On Windows, an ODBC driver manager is installed by default.
For Unix systems, there are some implementations which must be
installed first. Note that every end user of your application is
required to have an ODBC driver manager installed, otherwise the
QODBC plugin will not work.
When connecting to an ODBC datasource, you should pass the name
- of the ODBC datasource to the QSqlDatabase::setDatabaseName()
+ of the ODBC datasource (DSN) to the QSqlDatabase::setDatabaseName()
function, rather than the actual database name.
+ It's also possible to pass a FILEDSN (*.dsn) filename or a complete
+ ODBC driver string. When passing a driver string you must make sure,
+ that all parameters (username, password, ...) are properly escaped.
+ Passing the username or password through the QSqlDatabase functions,
+ the escaping is done by the QODBC plugin.
The QODBC Plugin needs an ODBC compliant driver manager version 2.0 or
later. Some ODBC drivers claim to be version-2.0-compliant,
@@ -347,17 +441,11 @@
e.g., the SQLSTATEs. Before setting this connect option, consult
your ODBC documentation about behavior differences you can expect.
- When using the SAP HANA database, the connection has to be
- established using the option "SCROLLABLERESULT=TRUE", as the
- HANA ODBC driver does not provide scrollable results by default, e.g.:
-
- \snippet code/doc_src_sql-driver.cpp 39
-
If you experience very slow access of the ODBC datasource, make sure
that ODBC call tracing is turned off in the ODBC datasource manager.
Some drivers do not support scrollable cursors. In that case, only
- queries in forwardOnly mode can be used successfully.
+ queries in \l QSqlQuery::setForwardOnly() mode can be used successfully.
\section3 ODBC Stored Procedure Support
@@ -368,18 +456,68 @@
\snippet code/doc_src_sql-driver.cpp 10
- \b{Note:} The value returned by the stored procedure's return statement
+ \note The value returned by the stored procedure's return statement
is discarded.
\section3 ODBC Unicode Support
The QODBC Plugin will use the Unicode API if UNICODE is defined. On
- Windows NT based systems, this is the default. Note that the ODBC
+ Windows based systems, this is the default. Note that the ODBC
driver and the DBMS must also support Unicode.
For the Oracle 9 ODBC driver (Windows), it is necessary to check
"SQL_WCHAR support" in the ODBC driver manager otherwise Oracle
- will convert all Unicode strings to local 8-bit.
+ will convert all Unicode strings to local 8-bit representation.
+
+ \section3 Connection options
+ The Qt ODBC plugin honors the following connection options:
+ \table
+ \header \li Attribute \li Possible value
+ \row
+ \li SQL_ATTR_ACCESS_MODE
+ \li SQL_MODE_READ_ONLY: open the database in read-only mode\br
+ SQL_MODE_READ_WRITE: open the database in read-write mode (default)
+ \row
+ \li SQL_ATTR_LOGIN_TIMEOUT
+ \li Number of seconds to wait for the database connection
+ during login (a value of 0 will wait forever)
+ \row
+ \li SQL_ATTR_CONNECTION_TIMEOUT
+ \li Number of seconds to wait for any request to the database
+ (a value of 0 will wait forever)
+ \row
+ \li SQL_ATTR_CURRENT_CATALOG
+ \li The catalog (database) to use for this connection
+ \row
+ \li SQL_ATTR_METADATA_ID
+ \li SQL_TRUE: the string argument of catalog functions are treated
+ as identifiers\br
+ SQL_FALSE: the string arguments of catalog functions are not
+ treated as identifiers
+ \row
+ \li SQL_ATTR_PACKET_SIZE
+ \li Specifies the network packet size in bytes
+ \row
+ \li SQL_ATTR_TRACEFILE
+ \li A string containing the name of the trace file
+ \row
+ \li SQL_ATTR_TRACE
+ \li SQL_OPT_TRACE_ON: Enable database query tracing\br
+ SQL_OPT_TRACE_OFF: Disable database query tracing (default)
+ \row
+ \li SQL_ATTR_CONNECTION_POOLING
+ \li Enable or disable connection pooling at the environment level.\br
+ SQL_CP_DEFAULT, SQL_CP_OFF: Connection pooling is turned off (default)\br
+ SQL_CP_ONE_PER_DRIVER: A single connection pool is supported for each driver\br
+ SQL_CP_ONE_PER_HENV: A single connection pool is supported for each environment
+ \row
+ \li SQL_ATTR_ODBC_VERSION
+ \li SQL_OV_ODBC3: The driver should act as a ODBC 3.x driver\br
+ SQL_OV_ODBC2: The driver should act as a ODBC 2.x driver (default)
+ \endtable
+ For more detailed information about the connect options please refer
+ to the \l {https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetconnectattr-function}
+ {SQLSetConnectAttr()} ODBC documentation.
\section3 How to Build the ODBC Plugin on Unix and \macos
@@ -387,9 +525,9 @@
version and ODBC drivers at \l http://www.unixodbc.org.
You need the unixODBC header files and shared libraries.
- Tell \c qmake where to find the unixODBC header files and shared
+ Tell \c qt-cmake where to find the unixODBC header files and shared
libraries (here it is assumed that unixODBC is installed in
- \c{/usr/local/unixODBC}) and run \c{make}:
+ \c{/usr/local/unixODBC}) and build:
\snippet code/doc_src_sql-driver.qdoc 11
@@ -400,11 +538,8 @@
\snippet code/doc_src_sql-driver.qdoc 12
- If you are not using a Microsoft compiler, replace \c nmake with \c
- mingw32-make in the line above.
-
\target QPSQL
- \section2 QPSQL for PostgreSQL (Version 7.3 and Above)
+ \section2 QPSQL for PostgreSQL (Version 7.3 and above)
The QPSQL driver supports version 7.3 and higher of the PostgreSQL server.
@@ -473,7 +608,7 @@
database connections, or if we execute query2 after the while loop.
\note Some methods of QSqlDatabase like tables(), primaryIndex()
- implicity execute SQL queries, so these also cannot be used while
+ implicitly execute SQL queries, so these also cannot be used while
navigating the results of forward-only query.
\note QPSQL will print the following warning if it detects a loss of
@@ -481,20 +616,25 @@
\snippet code/doc_src_sql-driver.qdoc 38
+ \section3 Connection options
+ The Qt PostgreSQL plugin honors all connection options specified in the
+ \l {https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS}
+ {connect()} PostgreSQL documentation.
+
\section3 How to Build the QPSQL Plugin on Unix and \macos
You need the PostgreSQL client library and headers installed.
- To make \c qmake find the PostgreSQL header files and shared
- libraries, run \c qmake the following way (assuming that the
- PostgreSQL client is installed in \c{/usr}):
+ To make \c qt-cmake find the PostgreSQL header files and shared
+ libraries, build the plugin the following way (assuming that the
+ PostgreSQL client is installed in \c{/usr/local/pgsql}):
\snippet code/doc_src_sql-driver.qdoc 13
\section3 How to Build the QPSQL Plugin on Windows
Install the appropriate PostgreSQL developer libraries for your
- compiler. Assuming that PostgreSQL was installed in \c{C:\psql},
+ compiler. Assuming that PostgreSQL was installed in \c{C:\pgsql},
build the plugin as follows:
\snippet code/doc_src_sql-driver.qdoc 15
@@ -507,7 +647,7 @@
as the application executable.
\target QDB2
- \section2 QDB2 for IBM DB2 (Version 7.1 and Above)
+ \section2 QDB2 for IBM DB2 (Version 7.1 and above)
The Qt DB2 plugin makes it possible to access IBM DB2 databases. It
has been tested with IBM DB2 v7.1 and 7.2. You must install the IBM
@@ -520,6 +660,20 @@
We suggest using a forward-only query when calling stored procedures
in DB2 (see QSqlQuery::setForwardOnly()).
+ \section3 Connection options
+ The Qt IBM DB2 plugin honors the following connection options:
+ \table
+ \header \li Attribute \li Possible value
+ \row
+ \li SQL_ATTR_ACCESS_MODE
+ \li SQL_MODE_READ_ONLY: open the database in read-only mode\br
+ SQL_MODE_READ_WRITE: open the database in read-write mode (default)
+ \row
+ \li SQL_ATTR_LOGIN_TIMEOUT
+ \li Number of seconds to wait for the database connection
+ during login (max: 32767, a value of 0 will wait forever)
+ \endtable
+
\section3 How to Build the QDB2 Plugin on Unix and \macos
\snippet code/doc_src_sql-driver.qdoc 18
@@ -531,11 +685,8 @@
\snippet code/doc_src_sql-driver.qdoc 20
- If you are not using a Microsoft compiler, replace \c nmake
- with \c mingw32-make in the line above.
-
\target QSQLITE
- \section2 QSQLITE for SQLite (Version 3 and Above)
+ \section2 QSQLITE for SQLite (Version 3 and above)
The Qt SQLite plugin makes it possible to access SQLite
databases. SQLite is an in-process database, which means that it
@@ -568,24 +719,77 @@
You can find information about SQLite on \l{http://www.sqlite.org}.
+ \section3 Connection options
+ The Qt SQLite plugin honors the following connection options:
+ \table
+ \header \li Attribute \li Possible value
+ \row
+ \li QSQLITE_BUSY_TIMEOUT
+ \li Busy handler timeout in milliseconds (val <= 0: disabled),
+ see \l {https://www.sqlite.org/c3ref/busy_timeout.html}
+ {SQLite documentation} for more information
+
+ \row
+ \li QSQLITE_USE_QT_VFS
+ \li If set, the database is opened using Qt's VFS which allows to
+ open databases using QFile. This way it can open databases from
+ any read-write locations (e.g.android shared storage) but also
+ from read-only resources (e.g. qrc or android assets). Be aware
+ that when opening databases from read-only resources make sure
+ you add QSQLITE_OPEN_READONLY attribute as well.
+ Otherwise it will fail to open it.
+
+ \row
+ \li QSQLITE_OPEN_READONLY
+ \li If set, the database is open in read-only mode which will fail
+ if no database exists. Otherwise the database will be opened in
+ read-write mode and created if the database file does not yet
+ exist (default)
+ \row
+ \li QSQLITE_OPEN_URI
+ \li The given filename is interpreted as an uri, see
+ \l {https://www.sqlite.org/c3ref/open.html} {SQLITE_OPEN_URI}
+ \row
+ \li QSQLITE_ENABLE_SHARED_CACHE
+ \li If set, the database is opened in
+ \l {https://www.sqlite.org/sharedcache.html} {shared cache mode},
+ otherwise in private cache mode
+ \row
+ \li QSQLITE_ENABLE_REGEXP
+ \li If set, the plugin defines a function 'regex' which can be used
+ in queries, QRegularExpression is used for evaluation of the regex query
+ \row
+ \li QSQLITE_NO_USE_EXTENDED_RESULT_CODES
+ \li Disables the usage of the \l {https://www.sqlite.org/c3ref/extended_result_codes.html}
+ {extended result code} feature in SQLite
+ \row
+ \li QSQLITE_ENABLE_NON_ASCII_CASE_FOLDING
+ \li If set, the plugin replaces the functions 'lower' and 'upper' with
+ QString functions for correct case folding of non-ascii characters
+ \row
+ \li QSQLITE_OPEN_NOFOLLOW
+ \li If set, the database filename is not allowed to contain a symbolic link
+ \endtable
+
\section3 How to Build the QSQLITE Plugin
SQLite version 3 is included as a third-party library within Qt.
- It can be built by passing the \c{-qt-sqlite} parameter to the
- configure script.
+ It can be built by passing the \c{-DFEATURE_system_sqlite=OFF} parameter to the
+ \c qt-cmake command line.
If you do not want to use the SQLite library included with Qt, you
- can pass \c{-system-sqlite} to the configure script to use the SQLite
- libraries of the operating system. This is recommended whenever possible,
- as it reduces the installation size and removes one component for which
- you need to track security advisories.
+ can pass \c{-DFEATURE_system_sqlite=ON} to the \c qt-cmake command
+ line to use the SQLite libraries of the operating system. This is
+ recommended whenever possible, as it reduces the installation size
+ and removes one component for which you need to track security
+ advisories.
On Unix and \macos (replace \c $SQLITE with the directory where
SQLite resides):
\snippet code/doc_src_sql-driver.qdoc 21
- On Windows:
+ On Windows (assuming that SQLite is installed in \c{C:\SQLITE}):
\snippet code/doc_src_sql-driver.qdoc 23
@@ -622,6 +826,47 @@
Some versions of SQLite can be forced to write a specific file format by setting
the \c{SQLITE_DEFAULT_FILE_FORMAT} define when building SQLite.
+ \target QMIMER
+ \section2 QMIMER for Mimer SQL version 11 and higher
+
+ The Qt Mimer SQL plugin makes it possible to work with the Mimer SQL RDBMS.
+ Mimer SQL provides small footprint, scalable and robust relational database
+ solutions that conform to international ISO SQL standards. Mimer SQL is available
+ on Windows, Linux, \macos, and OpenVMS as well as several embedded platforms like QNX, Android,
+ and embedded Linux.
+
+ Mimer SQL fully support Unicode. To work with Unicode data the column types National Character (NCHAR),
+ National Character Varying (NVARCHAR), or National Character Large Object (NCLOB) must be used.
+ For more information about Mimer SQL and unicode, see \l{https://developer.mimer.com/features/multilingual-support}
+
+ \section3 QMIMER Stored Procedure Support
+
+ Mimer SQL have stored procedures according to the SQL standard (PSM) and
+ the plugin fully support IN, OUT, INOUT parameters as well as resultset procedures.
+
+ Example stored procedure with INOUT and OUT parameters:
+
+ \snippet code/doc_src_sql-driver.qdoc 44
+
+ Source code to access the INOUT and OUT values:
+
+ \snippet code/doc_src_sql-driver.cpp 40
+
+ \section3 How to Build the QMIMER Plugin on Unix and \macos
+
+ You need the Mimer SQL header files and shared libraries. Get them by installing
+ any of the Mimer SQL variants found at \l{https://developer.mimer.com}.
+
+
+ \snippet code/doc_src_sql-driver.qdoc 31
+
+ \section3 How to Build the QMIMER Plugin on Windows
+
+ You need the Mimer SQL header files and shared libraries. Get them by installing
+ any of the Mimer SQL variants found at \l{https://developer.mimer.com}.
+
+ \snippet code/doc_src_sql-driver.qdoc 32
+
\target QIBASE
\section2 QIBASE for Borland InterBase
@@ -635,6 +880,17 @@
database file, no matter whether it is stored locally or on another
server.
+ \section3 Connection options
+ The Qt Borland InterBase plugin honors the following connection options:
+ \table
+ \header \li Attribute \li Possible value
+ \row
+ \li ISC_DPB_SQL_ROLE_NAME
+ \li Specifies the login role name
+ \endtable
+
+
+ \section3 How to Build the QIBASE Plugin
\snippet code/doc_src_sql-driver.cpp 24
You need the InterBase/Firebird development headers and libraries
@@ -644,20 +900,6 @@
Edition are not allowed to link this plugin to the commercial editions of
InterBase. Please use Firebird or the free edition of InterBase.
- \section3 QIBASE Unicode Support and Text Encoding
-
- By default the driver connects to the database using UNICODE_FSS. This can
- be overridden by setting the ISC_DPB_LC_CTYPE parameter with
- QSqlDatabase::setConnectOptions() before opening the connection.
-
- \snippet code/doc_src_sql-driver.cpp 25
-
- If Qt does not support the given text encoding the driver will issue a
- warning message and connect to the database using UNICODE_FSS.
-
- Note that if the text encoding set when connecting to the database is
- not the same as in the database, problems with transliteration might arise.
-
\section3 QIBASE Stored procedures
InterBase/Firebird return OUT values as result set, so when calling stored
@@ -688,13 +930,10 @@
\snippet code/doc_src_sql-driver.qdoc 29
- If you are using Firebird, the Firebird library has to be set explicitly:
+ If you are using Firebird:
\snippet code/doc_src_sql-driver.qdoc 30
- If you are not using a Microsoft compiler, replace \c nmake
- with \c mingw32-make in the line above.
-
Note that \c{C:\interbase\bin} must be in the \c PATH.
\target troubleshooting
@@ -702,7 +941,7 @@
You should always use client libraries that have been compiled with
the same compiler as you are using for your project. If you cannot get
- a source distibution to compile the client libraries yourself, you
+ a source distribution to compile the client libraries yourself, you
must make sure that the pre-compiled library is compatible with
your compiler, otherwise you will get a lot of "undefined symbols"
errors. Some compilers have tools to convert libraries, e.g. Borland
@@ -723,7 +962,7 @@
Qt Creator, you can update the \c PATH environment variable in the
\gui Run section of the \gui Project panel to include the path to
the folder containing the client libraries.
- \li Compile Qt with \c{QT_DEBUG_COMPONENT} defined to get very verbose
+ \li Compile Qt with \c{QT_DEBUG_PLUGINS} defined to get very verbose
debug output when loading plugins.
\endlist
diff --git a/src/sql/doc/src/sql-programming.qdoc b/src/sql/doc/src/sql-programming.qdoc
index 56bb48b27b..a7f87fe73f 100644
--- a/src/sql/doc/src/sql-programming.qdoc
+++ b/src/sql/doc/src/sql-programming.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\group database
@@ -520,11 +496,11 @@
submitted.
The items in the view are rendered using a delegate. The default
- delegate, QItemDelegate, handles the most common data types (\c
+ delegate, QStyledItemDelegate, handles the most common data types (\c
int, QString, QImage, etc.). The delegate is also responsible for
providing editor widgets (e.g., a combobox) when the user starts
editing an item in the view. You can create your own delegates by
- subclassing QAbstractItemDelegate or QItemDelegate. See
+ subclassing QAbstractItemDelegate or QStyledItemDelegate. See
\l{Model/View Programming} for more information.
QSqlTableModel is optimized to operate on a single table at a