VTK  9.2.5
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) override;
59
65 bool Open(const char* password = nullptr) override;
66
70 void Close() override;
71
75 bool IsOpen() override;
76
81
86
90 vtkStringArray* GetRecord(const char* table) override;
91
95 bool IsSupported(int feature) override;
96
100 bool HasError() override;
101
105 const char* GetLastErrorText() override;
106
108
111 const char* GetDatabaseType() override { return this->DatabaseType; }
113
115
118 vtkSetStringMacro(HostName);
119 vtkGetStringMacro(HostName);
121
123
126 vtkSetStringMacro(User);
127 vtkGetStringMacro(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 vtkStdString GetTablePreamble(bool b) override { return b ? vtkStdString() : "IF NOT EXISTS "; }
176
189 vtkSQLDatabaseSchema* schema, int tblHandle, int colHandle) override;
190
202 vtkSQLDatabaseSchema* schema, int tblHandle, int idxHandle, bool& skipped) override;
203
208 bool CreateDatabase(const char* dbName, bool dropExisting);
209
214 bool DropDatabase(const char* dbName);
215
221 bool ParseURL(const char* url) override;
222
223protected:
226
227private:
228 // We want this to be private, a user of this class
229 // should not be setting this for any reason
230 vtkSetStringMacro(DatabaseType);
231
232 vtkStringArray* Tables;
233 vtkStringArray* Record;
234
235 char* DatabaseType;
236 char* HostName;
237 char* User;
238 char* Password;
239 char* DatabaseName;
240 int ServerPort;
241 int Reconnect;
242
243 vtkMySQLDatabasePrivate* const Private;
244
245 vtkMySQLDatabase(const vtkMySQLDatabase&) = delete;
246 void operator=(const vtkMySQLDatabase&) = delete;
247};
248
249#endif // vtkMySQLDatabase_h
a simple class to control print indentation
Definition: vtkIndent.h:40
maintain a connection to a MySQL database
const char * GetLastErrorText() override
Get the last error text from the database.
static vtkMySQLDatabase * New()
bool IsOpen() override
Return whether the database has an open connection.
bool DropDatabase(const char *dbName)
Drop a database if it exists.
vtkStdString GetIndexSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int idxHandle, bool &skipped) override
Return the SQL string with the syntax to create an index inside a "CREATE TABLE" SQL statement.
bool CreateDatabase(const char *dbName, bool dropExisting)
Create a new database, optionally dropping any existing database of the same name.
vtkStringArray * GetRecord(const char *table) override
Get the list of fields for a particular table.
vtkStringArray * GetTables() override
Get the list of tables from the database.
bool HasError() override
Did the last operation generate an error.
const char * GetDatabaseType() override
String representing database type (e.g.
bool Open(const char *password=nullptr) override
Open a new connection to the database.
vtkStdString GetTablePreamble(bool b) override
Return the SQL string with the syntax of the preamble following a "CREATE TABLE" SQL statement.
vtkSQLQuery * GetQueryInstance() override
Return an empty query on this database.
bool IsSupported(int feature) override
Return whether a feature is supported by the database.
vtkStdString GetColumnSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle) override
Return the SQL string with the syntax to create a column inside a "CREATE TABLE" SQL statement.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Close() override
Close the connection to the database.
bool ParseURL(const char *url) override
Overridden to determine connection parameters given the URL.
~vtkMySQLDatabase() override
vtkStdString GetURL() override
Get the URL of the database.
vtkSQLQuery implementation for MySQL databases
Definition: vtkMySQLQuery.h:48
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:39
a vtkAbstractArray subclass for strings
#define VTK_INT_MAX
Definition: vtkType.h:155