1
/***************************************************************************
3
* This file is part of the KDE project
4
* copyright (C)2004-2006 by Sebastian Sauer (mail@dipe.org)
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
***************************************************************************/
20
#ifndef SCRIPTING_KEXIDBPARSER_H
21
#define SCRIPTING_KEXIDBPARSER_H
27
#include <KDbDriverManager>
33
// Forward declaration.
34
class KexiDBConnection;
35
class KexiDBTableSchema;
36
class KexiDBQuerySchema;
39
* The KexiDBParser could be used to parse SQL-statements.
41
* Example (in Python) ;
43
* # First we need a parser object.
44
* parser = connection.parser()
45
* # Parse a SQL-statement.
46
* parser.parse("SELECT * from table1")
47
* # The operation could be e.g. SELECT or INSERT.
48
* if parser.operation() == 'Error':
49
* raise parser.errorMsg()
50
* # Print some feedback.
51
* print "Successfully parsed the SQL-statement %s" % parser.statement()
54
class KexiDBParser : public QObject
58
KexiDBParser(KexiDBConnection* connection, KDbParser* parser, bool owner);
59
virtual ~KexiDBParser();
63
/** Clears previous results and runs the parser on the SQL statement passed as an argument. */
64
bool parse(const QString& sql);
65
/** Clears parsing results. */
67
/** Returns the resulting operation. */
68
const QString operation();
70
/** Returns the \a KexiDBTableSchema object on a CREATE TABLE operation. */
72
/** Returns the \a KexiDBQuerySchema object on a SELECT operation. */
74
/** Returns the \a KexiDBConnection object pointing to the used database connection. */
75
QObject* connection();
76
/** Returns the SQL query statement. */
77
const QString statement();
79
/** Returns the type string of the last error. */
80
const QString errorType();
81
/** Returns the message of the last error. */
82
const QString errorMsg();
83
/** Returns the position where the last error occurred. */
87
QPointer<KexiDBConnection> m_connection;