VTK  9.4.20241222
vtkMySQLDatabase.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
23#ifndef vtkMySQLDatabase_h
24#define vtkMySQLDatabase_h
25
26#include "vtkIOMySQLModule.h" // For export macro
27#include "vtkSQLDatabase.h"
28
29VTK_ABI_NAMESPACE_BEGIN
30class vtkSQLQuery;
31class vtkMySQLQuery;
32class vtkStringArray;
34
35class VTKIOMYSQL_EXPORT vtkMySQLDatabase : public vtkSQLDatabase
36{
37
38 friend class vtkMySQLQuery;
39
40public:
42 void PrintSelf(ostream& os, vtkIndent indent) override;
44
50 bool Open(const char* password = nullptr) override;
51
55 void Close() override;
56
60 bool IsOpen() override;
61
66
71
75 vtkStringArray* GetRecord(const char* table) override;
76
80 bool IsSupported(int feature) override;
81
85 bool HasError() override;
86
90 const char* GetLastErrorText() override;
91
93
96 const char* GetDatabaseType() override { return this->DatabaseType; }
98
100
103 vtkSetStringMacro(HostName);
104 vtkGetStringMacro(HostName);
106
108
111 vtkSetStringMacro(User);
112 vtkGetStringMacro(User);
114
116
119 vtkSetStringMacro(Password);
121
123
126 vtkSetStringMacro(DatabaseName);
127 vtkGetStringMacro(DatabaseName);
129
131
136 vtkSetMacro(Reconnect, int);
137 vtkGetMacro(Reconnect, int);
138 vtkBooleanMacro(Reconnect, int);
140
142
145 vtkSetClampMacro(ServerPort, int, 0, VTK_INT_MAX);
146 vtkGetMacro(ServerPort, int);
148
153
160 vtkStdString GetTablePreamble(bool b) override { return b ? vtkStdString() : "IF NOT EXISTS "; }
161
174 vtkSQLDatabaseSchema* schema, int tblHandle, int colHandle) override;
175
187 vtkSQLDatabaseSchema* schema, int tblHandle, int idxHandle, bool& skipped) override;
188
193 bool CreateDatabase(const char* dbName, bool dropExisting);
194
199 bool DropDatabase(const char* dbName);
200
206 bool ParseURL(const char* url) override;
207
208protected:
211
212private:
213 // We want this to be private, a user of this class
214 // should not be setting this for any reason
215 vtkSetStringMacro(DatabaseType);
216
217 vtkStringArray* Tables;
218 vtkStringArray* Record;
219
220 char* DatabaseType;
221 char* HostName;
222 char* User;
223 char* Password;
224 char* DatabaseName;
225 int ServerPort;
226 int Reconnect;
227
228 vtkMySQLDatabasePrivate* const Private;
229
230 vtkMySQLDatabase(const vtkMySQLDatabase&) = delete;
231 void operator=(const vtkMySQLDatabase&) = delete;
232};
233
234VTK_ABI_NAMESPACE_END
235#endif // vtkMySQLDatabase_h
a simple class to control print indentation
Definition vtkIndent.h:108
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
represent an SQL database schema
maintain a connection to an sql database
executes an sql query and retrieves results
Definition vtkSQLQuery.h:60
Wrapper around std::string to keep symbols short.
a vtkAbstractArray subclass for strings
#define VTK_INT_MAX
Definition vtkType.h:144