Hyper API for C++ 0.0.20746
Hyper client library for C++ applications
Loading...
Searching...
No Matches
Catalog.hpp
Go to the documentation of this file.
1
5#ifndef TABLEAU_HYPER_CATALOG_HPP
6#define TABLEAU_HYPER_CATALOG_HPP
7
10#include <hyperapi/impl/infra.hpp>
11#include <hyperapi/hyperapi.h>
12
13#include <string>
14#include <unordered_set>
15
16namespace hyperapi {
17
18class Connection;
19
31class Catalog final {
32 private:
37 explicit Catalog(Connection& connection) noexcept;
38
39 public:
40 Catalog(const Catalog&) = delete;
41 Catalog& operator=(const Catalog&) = delete;
42 Catalog(Catalog&&) = delete;
43 Catalog operator=(Catalog&&) = delete;
44
53 bool hasTable(const TableName& table) const;
54
66
74 void createSchema(const SchemaName& schemaName) const;
75
83 void createSchemaIfNotExists(const SchemaName& schemaName) const;
84
92 void createTable(const hyperapi::TableDefinition& table_definition) const;
93
101 void createTableIfNotExists(const hyperapi::TableDefinition& table_definition) const;
102
112 std::unordered_set<SchemaName> getSchemaNames() const;
113
121 std::unordered_set<SchemaName> getSchemaNames(const DatabaseName& database) const;
122
132 std::unordered_set<TableName> getTableNames(const SchemaName& schema) const;
133
142 void createDatabase(const std::string& databasePath);
143
153 void createDatabaseIfNotExists(const std::string& databasePath);
154
161 void detachDatabase(const DatabaseName& databaseName);
162
170 void attachDatabase(const std::string& databasePath, const DatabaseName& databaseName);
171
179 void attachDatabase(const std::string& databasePath);
180
191
203 void dropDatabase(const std::string& databasePath);
204
216 void dropDatabaseIfExists(const std::string& databasePath);
217
221 Connection& getConnection() const noexcept { return connection_; }
222
223 private:
225 Connection& connection_;
226
227 friend class Connection;
228};
229}
230
231#endif
The catalog class gives access to the metadata of the attached databases of a connection.
Definition Catalog.hpp:31
void createDatabaseIfNotExists(const std::string &databasePath)
Creates a database file with the given path if it doesn't exist yet.
void attachDatabase(const std::string &databasePath, const DatabaseName &databaseName)
Attaches a database file databasePath to the underlying connection under the name databaseName.
std::unordered_set< TableName > getTableNames(const SchemaName &schema) const
Gets the names of all tables in the given schema.
std::unordered_set< SchemaName > getSchemaNames(const DatabaseName &database) const
Gets the names of all schemas in database.
bool hasTable(const TableName &table) const
Checks whether a table with the given name exists.
void createSchema(const SchemaName &schemaName) const
Creates a SQL schema with the given name.
void detachAllDatabases()
Detaches all databases from the underlying connection.
void createDatabase(const std::string &databasePath)
Creates a database file with the given path.
void createTable(const hyperapi::TableDefinition &table_definition) const
Creates a SQL table with the given table definition.
Connection & getConnection() const noexcept
Returns the underlying connection.
Definition Catalog.hpp:221
void detachDatabase(const DatabaseName &databaseName)
Detaches a database from the underlying connection.
void attachDatabase(const std::string &databasePath)
Attaches a database file databasePath to the underlying connection.
void createTableIfNotExists(const hyperapi::TableDefinition &table_definition) const
Creates a SQL table with the given table definition.
std::unordered_set< SchemaName > getSchemaNames() const
Gets the name of all schemas in the first database in the database search path.
TableDefinition getTableDefinition(const TableName &tableName) const
Gets the table definition for an existing table.
void dropDatabaseIfExists(const std::string &databasePath)
Drops the database with the given path.
void dropDatabase(const std::string &databasePath)
Drops the database with the given path.
void createSchemaIfNotExists(const SchemaName &schemaName) const
Creates a SQL schema with the given name.
Defines a Hyper connection.
Represents an escaped SQL database name.
Represents an escaped SQL schema name.
Represents an escaped SQL table name.
Definition TableName.hpp:15
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15