summaryrefslogtreecommitdiffstats
path: root/src/sql/doc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql/doc')
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver.qdoc70
-rw-r--r--src/sql/doc/snippets/sqldatabase/sqldatabase.cpp10
-rw-r--r--src/sql/doc/src/qsqldatatype-table.qdoc63
-rw-r--r--src/sql/doc/src/sql-driver.qdoc137
4 files changed, 114 insertions, 166 deletions
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 9709deeccb..c7cc06bca5 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
@@ -54,7 +54,7 @@
Database options:
-sql-<driver> ........ Enable SQL <driver> plugin. Supported drivers:
- db2 ibase mysql oci odbc psql sqlite2 sqlite tds
+ db2 ibase mysql oci odbc psql sqlite
[all auto]
-sqlite .............. Select used sqlite3 [system/qt]
@@ -70,7 +70,6 @@ BEGIN
END
//! [1]
-
//! [3]
cd $QTDIR/qtbase/src/plugins/sqldrivers
qmake -- MYSQL_PREFIX=/usr/local
@@ -86,14 +85,15 @@ make install
//! [5]
cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt"
+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
//! [5]
//! [6]
cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- "OCI_INCDIR=$ORACLE_HOME/rdbms/public" OCI_LIBDIR=$ORACLE_HOME/lib "OCI_LIBS=-lclntsh -lwtc9"
+qmake -- OCI_INCDIR="$ORACLE_HOME/rdbms/public" OCI_LIBDIR="$ORACLE_HOME/lib" OCI_LIBS="-lclntsh -lwtc9"
make sub-oci
//! [6]
@@ -142,23 +142,10 @@ make sub-psql
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- PSQL_INCDIR=C:/psql/include PSQL_LIBDIR=C:/psql/lib/ms
nmake sub-psql
+nmake install
//! [15]
-//! [16]
-cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- TDS_PREFIX=$SYBASE
-make sub-tds
-//! [16]
-
-
-//! [17]
-cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake
-nmake sub-tds
-//! [17]
-
-
//! [18]
cd $QTDIR/qtbase/src/plugins/sqldrivers
qmake -- DB2_PREFIX=$DB2DIR
@@ -168,8 +155,9 @@ make sub-db2
//! [20]
cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- "DB2_PREFIX=<DB2 home>/sqllib"
+qmake -- DB2_PREFIX="<DB2 home>/sqllib"
nmake sub-db2
+nmake install
//! [20]
@@ -184,6 +172,7 @@ make sub-sqlite
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- -system-sqlite SQLITE3_PREFIX=C:/SQLITE
nmake sub-sqlite
+nmake install
//! [23]
@@ -205,6 +194,7 @@ make sub-ibase
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- IBASE_INCDIR=C:/interbase/include
nmake sub-ibase
+nmake install
//! [29]
@@ -212,24 +202,25 @@ nmake sub-ibase
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- IBASE_INCDIR=C:/interbase/include IBASE_LIBS=-lfbclient
nmake sub-ibase
+nmake install
//! [30]
//! [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"
+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]
//! [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"
+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]
//! [35]
QSqlDatabase: QPSQL driver not loaded
-QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
+QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QMARIADB QODBC QODBC3 QPSQL QPSQL7
Could not create database object
//! [35]
@@ -250,3 +241,38 @@ q.exec(QString("CREATE TABLE %1 (id INTEGER)").arg(tableString));
// Call toLower() on the string so that it can be matched
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.
+
+Configure summary:
+
+Qt Sql Drivers:
+ DB2 (IBM) .............................. no
+ InterBase .............................. no
+ MySql .................................. yes
+ OCI (Oracle) ........................... no
+ ODBC ................................... yes
+ PostgreSQL ............................. no
+ SQLite ................................. yes
+ Using system provided SQLite ......... no
+
+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'.
+
+Prior to reconfiguration, make sure you remove any leftovers from the previous build.
+//! [41]
diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
index bba0487452..a45b5f409a 100644
--- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
+++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
@@ -249,16 +249,15 @@ void QSqlQueryModel_snippets()
}
//! [21]
- QSqlTableModel model;
- model.setTable("employee");
- model.select();
+ 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, 2)).toInt();
+ int salary = model.data(model.index(4, 1)).toInt();
//! [22]
Q_UNUSED(salary);
}
@@ -308,7 +307,8 @@ void QSqlTableModel_snippets()
//! [25]
QSqlTableModel model;
model.setTable("employee");
- QString name = model.record(4).value("name").toString();
+ model.select();
+ int salary = model.record(4).value("salary").toInt();
//! [25]
}
}
diff --git a/src/sql/doc/src/qsqldatatype-table.qdoc b/src/sql/doc/src/qsqldatatype-table.qdoc
index aafbed6096..1c5ab741c9 100644
--- a/src/sql/doc/src/qsqldatatype-table.qdoc
+++ b/src/sql/doc/src/qsqldatatype-table.qdoc
@@ -502,67 +502,4 @@
\li The value is a BLOB of data, stored exactly as it was input.
\li Mapped to QByteArray
\endtable
-
- \section2 Sybase Adaptive Server Data Types
-
- \table 90%
- \header
- \li Sybase Adaptive Server data type
- \li SQL type description
- \li Recommended input (C++ or Qt data type)
- \row
- \li BINARY
- \li Describes a fixed-length binary value up to 255 bytes in size.
- \li Mapped to QByteArray
- \row
- \li CHAR
- \li Character String
- \li Mapped to QString
- \row
- \li DATETIME
- \li Date and time. Range: 1753-01-01 00:00:00 through 9999-12-31 23:59:59.
- \li Mapped to QDateTime
- \row
- \li NCHAR
- \li Character String of fixed length
- \li Mapped to QString
- \row
- \li NVARACHAR
- \li Character String of variable length
- \li Mapped to QString
- \row
- \li VARCHAR
- \li Character String of fixed length
- \li Mapped to QString
- \row
- \li CLOB
- \li Character large string object
- \li Mapped to QString
- \row
- \li TIMESTAMP
- \li A unique number within a database
- \li Mapped to QString
- \row
- \li SMALLDATETIME
- \li Date and time. Range: 1900-01-01 00:00 through 2079-12-31 23:59
- \li Mapped to QDateTime
- \row
- \li UNICHAR
- \li Character String of fixed length.(Unicode)
- \li Mapped to QString
- \row
- \li UNIVARCHAR
- \li Character String of variable length.(Unicode)
- \li Mapped to QString
- \row
- \li VARBINARY
- \li Describes a variable-length binary value up to 255 bytes in size
- \li Mapped to QByteArray
- \endtable
-
- \section2 SQLite Version 2
-
- SQLite version 2 is "typeless". This means that you can store any kind of
- data you want in any column of any table, regardless of the declared
- data type of that column. We recommend that you map the data to QString.
*/
diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc
index c6ac4d17ff..28841a58de 100644
--- a/src/sql/doc/src/sql-driver.qdoc
+++ b/src/sql/doc/src/sql-driver.qdoc
@@ -48,15 +48,13 @@
\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
- \row \li \l{#QMYSQL}{QMYSQL} \li MySQL
+ \row \li \l{#QMYSQL}{QMYSQL / MARIADB} \li MySQL or MariaDB (version 5.0 and above)
\row \li \l{#QOCI}{QOCI} \li Oracle Call Interface Driver
\row \li \l{#QODBC}{QODBC}
\li Open Database Connectivity (ODBC) - Microsoft SQL Server and other
ODBC-compliant databases
\row \li \l{#QPSQL}{QPSQL} \li PostgreSQL (versions 7.3 and above)
- \row \li \l{#QSQLITE2}{QSQLITE2} \li SQLite version 2 \note obsolete since Qt 5.14
\row \li \l{#QSQLITE}{QSQLITE} \li SQLite version 3
- \row \li \l{#QTDS}{QTDS} \li Sybase Adaptive Server \note obsolete since Qt 4.7
\endtable
SQLite is the in-process database system with the best test coverage
@@ -70,7 +68,8 @@
access to the API exposed by the DBMS, and is typically shipped with it.
Most installation programs also allow you to install "development
libraries", and these are what you need. These libraries are responsible
- for the low-level communication with the DBMS.
+ for the low-level communication with the DBMS. Also make sure to install
+ the correct database libraries for your Qt architecture (32 or 64 bit).
\note When using Qt under Open Source terms but with a proprietary
database, verify the client library's license compatibility with
@@ -91,11 +90,21 @@
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:\mysql} on Windows), then pass the following parameter to
- configure: \c MYSQL_PREFIX=/usr/local/mysql
- (or \c{MYSQL_PREFIX=C:\mysql} for Windows).
+ \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).
The particulars for each driver are explained below.
+ 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.
+
+ A typical qmake run (in this case to configure for MySQL) looks like this:
+
+ \snippet code/doc_src_sql-driver.qdoc 41
+
Due to the practicalities of dealing with external dependencies,
only the SQLite3 plugin is shipped with binary builds of Qt.
To be able to add additional drivers to the Qt installation
@@ -112,11 +121,17 @@
\section1 Driver Specifics
\target QMYSQL
- \section2 QMYSQL for MySQL 4 and higher
+ \section2 QMYSQL for MySQL or MariaDB 5 and higher
+
+ MariaDB is a fork of MySQL intended to remain free and open-source software
+ under the GNU General Public License. MariaDB intended to maintain high
+ compatibility with MySQL, ensuring a drop-in replacement capability with
+ library binary parity and exact matching with MySQL APIs and commands.
+ Therefore the plugin for MySQL and MariaDB are combined into one Qt plugin.
\section3 QMYSQL Stored Procedure Support
- MySQL 5 introduces stored procedure support at the SQL level, but no
+ MySQL 5 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().
@@ -147,28 +162,53 @@
\section3 How to Build the QMYSQL Plugin on Unix and \macos
- You need the MySQL header files, as well as the shared library
- \c{libmysqlclient.so}. Depending on your Linux distribution, you may
- need to install a package which is usually called "mysql-devel".
+ You need the MySQL / MariaDB header files, as well as the shared library
+ \c{libmysqlclient.so} / \c{libmariadb.so}. 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 header files and shared
- libraries (here it is assumed that MySQL is installed in
+ Tell \l qmake 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}:
\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. Run \c SETUP.EXE and
- choose "Custom Install". Install the "Libs & Include Files" Module.
- Build the plugin as follows (here it is assumed that MySQL is
- installed in \c{C:\MySQL}):
+ 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}.
+ Run the installer,
+ select custom installation and install the MySQL C Connector
+ which matches your Qt installation (x86 or x64).
+ After installation make sure that the needed files are there:
+ \list
+ \li \c {<MySQL dir>/lib/libmysql.lib}
+ \li \c {<MySQL dir>/lib/libmysql.dll}
+ \li \c {<MySQL dir>/include/mysql.h}
+ \endlist
+ and for MariaDB
+ \list
+ \li \c {<MariaDB dir>/lib/libmariadb.lib}
+ \li \c {<MariaDB dir>/lib/libmariadb.dll}
+ \li \c {<MariaDB dir>/include/mysql.h}
+ \endlist
+
+ Build the plugin as follows (here it is assumed that the MySQL
+ C Connector is installed in
+ \c{C:/Program Files/MySQL/MySQL Connector C 6.1}):
\snippet code/doc_src_sql-driver.qdoc 5
If you are not using a Microsoft compiler, replace \c nmake with \c
mingw32-make in the line above.
+ When you distribute your application, remember to include libmysql.dll / libmariadb.dll
+ in your installation package. It must be placed in the same folder
+ as the application executable. \e libmysql.dll additionally needs the
+ MSVC runtime libraries which can be installed with vcredist.exe
+ (\l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}{vcredist.exe}
+
\target QOCI
\section2 QOCI for the Oracle Call Interface (OCI)
@@ -329,10 +369,6 @@
Windows NT based systems, this is the default. Note that the ODBC
driver and the DBMS must also support Unicode.
- Some driver managers and drivers do not support UNICODE. To use the
- QODBC plugin with such drivers, it has to be compiled with
- Q_ODBC_VERSION_2 defined.
-
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.
@@ -398,11 +434,6 @@
\snippet code/doc_src_sql-driver.qdoc 40
- \section3 QPSQL BLOB Support
-
- Binary Large Objects are supported through the \c BYTEA field type in
- PostgreSQL server versions >= 7.1.
-
\section3 QPSQL Forward-only query support
To use forward-only queries, you must build the QPSQL plugin with
@@ -463,48 +494,9 @@
Users of MinGW may wish to consult the following online document:
\l{http://www.postgresql.org/docs/current/static/installation-platform-notes.html#INSTALLATION-NOTES-MINGW}{PostgreSQL MinGW/Native Windows}.
- \target QTDS
- \section2 QTDS for Sybase Adaptive Server
-
- \note TDS is no longer used by MS Sql Server, and is superseded by
- \l{QODBC}{ODBC}. QTDS is obsolete from Qt 4.7.
-
- It is not possible to set the port with QSqlDatabase::setPort() due to limitations in the
- Sybase client library. Refer to the Sybase documentation for information on how to set up
- a Sybase client configuration file to enable connections to databases on non-default ports.
-
- \section3 How to Build the QTDS Plugin on Unix and \macos
-
- Under Unix, two libraries are available which support the TDS protocol:
-
- \list
- \li FreeTDS, a free implementation of the TDS protocol
- (\l{http://www.freetds.org}).
-
- \li Sybase Open Client, available from \l{https://support.sap.com}.
- \endlist
-
- Regardless of which library you use, the shared object file
- \c{libsybdb.so} is needed. Set the \c SYBASE environment variable to
- point to the directory where you installed the client library and
- execute \c{qmake}:
-
- \snippet code/doc_src_sql-driver.qdoc 16
-
- \section3 How to Build the QDTS Plugin on Windows
-
- You can either use the DB-Library supplied by Microsoft or the Sybase
- Open Client (\l{https://support.sap.com}). Configure will try to find
- NTWDBLIB.LIB to build the plugin:
-
- \snippet code/doc_src_sql-driver.qdoc 17
-
- By default, the Microsoft library is used on Windows. If you want to
- force the use of the Sybase Open Client, you must define \c
- Q_USE_SYBASE in \c{%QTDIR%\qtbase\src\plugins\sqldrivers\tds\qsql_tds.cpp}.
-
- If you are not using a Microsoft compiler, replace \c nmake
- with \c mingw32-make in the line above.
+ When you distribute your application, remember to include libpq.dll
+ in your installation package. It must be placed in the same folder
+ as the application executable.
\target QDB2
\section2 QDB2 for IBM DB2 (Version 7.1 and Above)
@@ -534,13 +526,6 @@
If you are not using a Microsoft compiler, replace \c nmake
with \c mingw32-make in the line above.
- \target QSQLITE2
- \section2 QSQLITE2 for SQLite Version 2
-
- The Qt SQLite 2 plugin is offered for compatibility. Whenever
- possible, use the \l{#QSQLITE}{version 3 plugin} instead. The
- build instructions for version 3 apply to version 2 as well.
-
\target QSQLITE
\section2 QSQLITE for SQLite (Version 3 and Above)