Hyper API for C++ 0.0.24081
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
9#include <hyperapi/impl/infra.hpp>
10
11#include <string>
12#include <unordered_set>
13
14namespace hyperapi {
15
16class Connection;
17
29class Catalog final {
30 private:
35 explicit Catalog(Connection& connection) noexcept;
36
37 public:
38 Catalog(const Catalog&) = delete;
39 Catalog& operator=(const Catalog&) = delete;
40 Catalog(Catalog&&) = delete;
41 Catalog operator=(Catalog&&) = delete;
42
51 bool hasTable(const TableName& table) const;
52
64
72 void createSchema(const SchemaName& schemaName) const;
73
81 void createSchemaIfNotExists(const SchemaName& schemaName) const;
82
90 void createTable(const hyperapi::TableDefinition& table_definition) const;
91
99 void createTableIfNotExists(const hyperapi::TableDefinition& table_definition) const;
100
110 std::unordered_set<SchemaName> getSchemaNames() const;
111
119 std::unordered_set<SchemaName> getSchemaNames(const DatabaseName& database) const;
120
130 std::unordered_set<TableName> getTableNames(const SchemaName& schema) const;
131
140 void createDatabase(const std::string& databasePath);
141
151 void createDatabaseIfNotExists(const std::string& databasePath);
152
159 void detachDatabase(const DatabaseName& databaseName);
160
168 void attachDatabase(const std::string& databasePath, const DatabaseName& databaseName);
169
177 void attachDatabase(const std::string& databasePath);
178
189
201 void dropDatabase(const std::string& databasePath);
202
214 void dropDatabaseIfExists(const std::string& databasePath);
215
219 Connection& getConnection() const noexcept { return connection_; }
220
221 private:
223 Connection& connection_;
224
225 friend class Connection;
226};
227}
228
229#endif
The catalog class gives access to the metadata of the attached databases of a connection.
Definition Catalog.hpp:29
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:219
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:14