Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsql_odbc_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QSQL_ODBC_H
6#define QSQL_ODBC_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtSql/qsqldriver.h>
20
21#if defined (Q_OS_WIN32)
22#include <QtCore/qt_windows.h>
23#endif
24
25#ifdef QT_PLUGIN
26#define Q_EXPORT_SQLDRIVER_ODBC
27#else
28#define Q_EXPORT_SQLDRIVER_ODBC Q_SQL_EXPORT
29#endif
30
31#ifdef Q_OS_UNIX
32#define HAVE_LONG_LONG 1 // force UnixODBC NOT to fall back to a struct for BIGINTs
33#endif
34
35#if defined(Q_CC_BOR)
36// workaround for Borland to make sure that SQLBIGINT is defined
37# define _MSC_VER 900
38#endif
39#include <sql.h>
40#if defined(Q_CC_BOR)
41# undef _MSC_VER
42#endif
43
44#include <sqlext.h>
45
47
49
50class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver
51{
52 Q_DECLARE_PRIVATE(QODBCDriver)
53 Q_OBJECT
54 friend class QODBCResultPrivate;
55
56public:
57 explicit QODBCDriver(QObject *parent=nullptr);
58 QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=nullptr);
59 virtual ~QODBCDriver();
60 bool hasFeature(DriverFeature f) const override;
61 void close() override;
62 QSqlResult *createResult() const override;
63 QStringList tables(QSql::TableType) const override;
64 QSqlRecord record(const QString &tablename) const override;
65 QSqlIndex primaryIndex(const QString &tablename) const override;
66 QVariant handle() const override;
67 QString formatValue(const QSqlField &field,
68 bool trimStrings) const override;
69 bool open(const QString &db,
70 const QString &user,
71 const QString &password,
72 const QString &host,
73 int port,
74 const QString &connOpts) override;
75
76 QString escapeIdentifier(const QString &identifier, IdentifierType type) const override;
77
78 bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const override;
79
80protected:
81 bool beginTransaction() override;
82 bool commitTransaction() override;
83 bool rollbackTransaction() override;
84
85private:
86 bool endTrans();
87 void cleanup();
88};
89
90QT_END_NAMESPACE
91
92#endif // QSQL_ODBC_H
QSqlDriver * create(const QString &) override
Creates and returns a QSqlDriver object for the driver called key.
Definition main.cpp:29
#define Q_EXPORT_SQLDRIVER_ODBC
Definition qsql_odbc_p.h:28