sqlite/sqliteadmin.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tqdir.h>
21
22#include "sqliteadmin.h"
23#include <kexidb/drivermanager.h>
24#include <kexidb/driver_p.h>
25
26#ifndef SQLITE2
27# include "sqlitevacuum.h"
28#endif
29
30SQLiteAdminTools::SQLiteAdminTools()
31 : KexiDB::AdminTools()
32{
33}
34
35SQLiteAdminTools::~SQLiteAdminTools()
36{
37}
38
39bool SQLiteAdminTools::vacuum(const KexiDB::ConnectionData& data, const TQString& databaseName)
40{
41 clearError();
42#ifdef SQLITE2
43 Q_UNUSED(data);
44 Q_UNUSED(databaseName);
45 return false;
46#else
48 KexiDB::Driver *drv = manager.driver(data.driverName);
49 TQString title( i18n("Could not compact database \"%1\".").arg(TQDir::convertSeparators(databaseName)) );
50 if (!drv) {
51 setError(&manager, title);
52 return false;
53 }
54 SQLiteVacuum vacuum(data.dbPath()+TQDir::separator()+databaseName);
55 tristate result = vacuum.run();
56 if (!result) {
57 setError(title);
58 return false;
59 }
60 else //success or cancelled
61 return true;
62#endif
63}
64
TQString driverName
the name of the driver that should be used to create a connection
Database specific connection data, e.g. host, port.
TQString dbPath() const
The directory the database file is in.
Database driver management, e.g. finding and loading drivers.
Driver * driver(const TQString &name)
Generic database abstraction.
Definition driver.h:67
virtual void clearError()
Definition object.cpp:131
virtual void setError(int code=ERR_OTHER, const TQString &msg=TQString())
Definition object.cpp:53
virtual bool vacuum(const KexiDB::ConnectionData &data, const TQString &databaseName)
Helper class performing interactive compacting (VACUUM) of the SQLite database.
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition tristate.h:100
High-level database connectivity library with database backend drivers.