kexidbconnection.h
1/***************************************************************************
2 * kexidbconnection.h
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20#ifndef KROSS_KEXIDB_KEXIDBCONNECTION_H
21#define KROSS_KEXIDB_KEXIDBCONNECTION_H
22
23#include <tqstring.h>
24#include <ksharedptr.h>
25
26#include <api/object.h>
27#include <api/variant.h>
28#include <api/list.h>
29#include <api/class.h>
30
31//#include <kexidb/driver.h>
32#include <kexidb/connection.h>
33
34namespace Kross { namespace KexiDB {
35
36 // Forward declarations.
37 class KexiDBDriver;
39 class KexiDBCursor;
43 class KexiDBParser;
44
68 class KexiDBConnection : public Kross::Api::Class<KexiDBConnection>
69 {
70 public:
71 KexiDBConnection(::KexiDB::Connection* connection, KexiDBDriver* driver = 0, KexiDBConnectionData* connectiondata = 0);
72 virtual ~KexiDBConnection();
73 virtual const TQString getClassName() const;
74
75 private:
76
78 bool hadError() const;
80 const TQString lastError() const;
81
85 KexiDBDriver* driver();
86
88 bool connect();
90 bool isConnected();
92 bool disconnect();
93
95 bool isReadOnly() const;
96
98 bool databaseExists(const TQString& dbname);
101 const TQString currentDatabase() const;
103 const TQStringList databaseNames() const;
105 bool isDatabaseUsed() const;
108 bool useDatabase(const TQString& dbname);
110 bool closeDatabase();
111
114 const TQStringList allTableNames() const;
116 const TQStringList tableNames() const;
118 const TQStringList queryNames() const;
119
122 KexiDBCursor* executeQueryString(const TQString& sqlquery);
125 KexiDBCursor* executeQuerySchema(KexiDBQuerySchema* queryschema);
126
127//TODO replace following method with a proxymethod.
129 Kross::Api::Object::Ptr insertRecord(Kross::Api::List::Ptr);
130
132 bool createDatabase(const TQString& dbname);
134 bool dropDatabase(const TQString& dbname);
135
137 bool createTable(KexiDBTableSchema* tableschema);
139 bool dropTable(const TQString& tablename);
142 bool alterTable(KexiDBTableSchema* fromschema, KexiDBTableSchema* toschema);
145 bool alterTableName(KexiDBTableSchema* tableschema, const TQString& newtablename);
146
149 KexiDBTableSchema* tableSchema(const TQString& tablename) const;
151 bool isEmptyTable(KexiDBTableSchema* tableschema) const;
153 KexiDBQuerySchema* querySchema(const TQString& queryname) const;
154
156 bool autoCommit() const;
159 bool setAutoCommit(bool enabled);
160
162 KexiDBTransaction* beginTransaction();
164 bool commitTransaction(KexiDBTransaction* transaction);
166 bool rollbackTransaction(KexiDBTransaction* transaction);
168 KexiDBTransaction* defaultTransaction();
171 void setDefaultTransaction(KexiDBTransaction* transaction);
172
174 Kross::Api::List* transactions();
175
177 KexiDBParser* parser();
178
179 private:
180 ::KexiDB::Connection* connection() const;
181 ::KexiDB::Connection* m_connection;
182
183 TDESharedPtr<KexiDBConnectionData> m_connectiondata;
184 TDESharedPtr<KexiDBDriver> m_driver;
185
187 void initialize();
188
189 };
190
191}}
192
193#endif
194
Provides database connection, allowing queries and data modification.
Definition connection.h:62
A KexiDBConnectionData is used to store the details needed for a connection with a database.
A connection to a database.
The cursor provides a control structure for the successive traversal of records in a result set as re...
Drivers are the implementations Kexi uses to access the driver-backends.
The KexiDBParser could be used to parse SQL-statements.
The KexiDBTableSchema object implements a KexiDBSchema for queries.
The KexiDBTableSchema object implements a KexiDBSchema for tables.
Transactions are used to ensure that integrity of a database is maintained.
High-level database connectivity library with database backend drivers.