VTK
vtkMySQLDatabase.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMySQLDatabase.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15/*-------------------------------------------------------------------------
16 Copyright 2008 Sandia Corporation.
17 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18 the U.S. Government retains certain rights in this software.
19-------------------------------------------------------------------------*/
39#ifndef vtkMySQLDatabase_h
40#define vtkMySQLDatabase_h
41
42#include "vtkIOMySQLModule.h" // For export macro
43#include "vtkSQLDatabase.h"
44
45class vtkSQLQuery;
46class vtkMySQLQuery;
47class vtkStringArray;
49
50class VTKIOMYSQL_EXPORT vtkMySQLDatabase : public vtkSQLDatabase
51{
52
53 friend class vtkMySQLQuery;
54
55public:
57 void PrintSelf(ostream& os, vtkIndent indent);
59
65 bool Open( const char* password = 0 );
66
70 void Close();
71
75 bool IsOpen();
76
81
86
90 vtkStringArray* GetRecord(const char *table);
91
95 bool IsSupported(int feature);
96
100 bool HasError();
101
105 const char* GetLastErrorText();
106
108
111 vtkGetStringMacro(DatabaseType);
113
115
118 vtkSetStringMacro(HostName);
121
123
126 vtkSetStringMacro(User);
129
131
134 vtkSetStringMacro(Password);
136
138
141 vtkSetStringMacro(DatabaseName);
142 vtkGetStringMacro(DatabaseName);
144
146
151 vtkSetMacro(Reconnect,int);
152 vtkGetMacro(Reconnect,int);
153 vtkBooleanMacro(Reconnect,int);
155
157
160 vtkSetClampMacro(ServerPort, int, 0, VTK_INT_MAX);
161 vtkGetMacro(ServerPort, int);
163
168
175 virtual vtkStdString GetTablePreamble( bool b ) { return b ? vtkStdString() :"IF NOT EXISTS "; }
176
189 int tblHandle,
190 int colHandle );
191
203 int tblHandle,
204 int idxHandle,
205 bool& skipped );
206
211 bool CreateDatabase( const char* dbName, bool dropExisting );
212
217 bool DropDatabase( const char* dbName );
218
224 virtual bool ParseURL(const char* url);
225
226protected:
229
230private:
231 // We want this to be private, a user of this class
232 // should not be setting this for any reason
233 vtkSetStringMacro(DatabaseType);
234
235 vtkStringArray *Tables;
236 vtkStringArray *Record;
237
238 char* DatabaseType;
239 char* HostName;
240 char* User;
241 char* Password;
242 char* DatabaseName;
243 int ServerPort;
244 int Reconnect;
245
246 vtkMySQLDatabasePrivate* const Private;
247
248 vtkMySQLDatabase(const vtkMySQLDatabase &) VTK_DELETE_FUNCTION;
249 void operator=(const vtkMySQLDatabase &) VTK_DELETE_FUNCTION;
250};
251
252#endif // vtkMySQLDatabase_h
253
a simple class to control print indentation
Definition: vtkIndent.h:40
maintain a connection to a MySQL database
void Close()
Close the connection to the database.
static vtkMySQLDatabase * New()
bool DropDatabase(const char *dbName)
Drop a database if it exists.
vtkSQLQuery * GetQueryInstance()
Return an empty query on this database.
bool CreateDatabase(const char *dbName, bool dropExisting)
Create a new database, optionally dropping any existing database of the same name.
bool IsOpen()
Return whether the database has an open connection.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual vtkStdString GetTablePreamble(bool b)
Return the SQL string with the syntax of the preamble following a "CREATE TABLE" SQL statement.
const char * GetLastErrorText()
Get the last error text from the database.
bool IsSupported(int feature)
Return whether a feature is supported by the database.
virtual bool ParseURL(const char *url)
Overridden to determine connection parameters given the URL.
bool HasError()
Did the last operation generate an error.
vtkStringArray * GetRecord(const char *table)
Get the list of fields for a particular table.
vtkStringArray * GetTables()
Get the list of tables from the database.
bool Open(const char *password=0)
Open a new connection to the database.
virtual vtkStdString GetColumnSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle)
Return the SQL string with the syntax to create a column inside a "CREATE TABLE" SQL statement.
virtual vtkStdString GetIndexSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int idxHandle, bool &skipped)
Return the SQL string with the syntax to create an index inside a "CREATE TABLE" SQL statement.
virtual vtkStdString GetURL()
Get the URL of the database.
vtkSQLQuery implementation for MySQL databases
Definition: vtkMySQLQuery.h:48
friend class vtkMySQLDatabase
Definition: vtkMySQLQuery.h:50
represent an SQL database schema
maintain a connection to an sql database
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:75
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
a vtkAbstractArray subclass for strings
@ url
Definition: vtkX3D.h:233
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
#define VTK_INT_MAX
Definition: vtkType.h:153