45static void runInsertDataIntoMultipleTables() {
46 std::cout <<
"EXAMPLE - Insert data into multiple tables within a new Hyper file" << std::endl;
47 const std::string pathToDatabase =
"data/superstore.hyper";
68 inserter.addRow(
static_cast<int16_t
>(399),
"DK-13375",
hyperapi::Date{2012, 9, 7},
"CA-2011-100006",
hyperapi::Date{2012, 9, 13},
"Standard Class");
69 inserter.addRow(
static_cast<int16_t
>(530),
"EB-13705",
hyperapi::Date{2012, 7, 8},
"CA-2011-100090",
hyperapi::Date{2012, 7, 12},
"Standard Class");
76 inserter.addRow(
"DK-13375",
"Dennis Kane", 518,
"Consumer");
77 inserter.addRow(
"EB-13705",
"Ed Braxton", 815,
"Corporate");
84 inserter.addRow(
"TEC-PH-10002075",
"Technology",
"Phones",
"AT&T EL51110 DECT");
91 inserter.addRow(2718,
"CA-2011-100006",
"TEC-PH-10002075", 377.97, int16_t{3}, 0.0, 109.6113);
92 inserter.addRow(2719,
"CA-2011-100090",
"TEC-PH-10002075", 377.97, int16_t{3}, hyperapi::null, 109.6113);
98 int64_t rowCount = connection.executeScalarQuery<int64_t>(
"SELECT COUNT(*) FROM " + tableName.toString());
99 std::cout <<
"The number of rows in table " << tableName <<
" is " << rowCount <<
"." << std::endl;
102 std::cout <<
"The connection to the Hyper file has been closed." << std::endl;
104 std::cout <<
"The Hyper Process has been shut down." << std::endl;
109 runInsertDataIntoMultipleTables();
111 std::cout << e.
toString() << std::endl;
The catalog class gives access to the metadata of the attached databases of a connection.
void createTable(const hyperapi::TableDefinition &table_definition) const
Creates a SQL table with the given table definition.
Defines a Hyper connection.
Defines an exception object that is thrown on failure by the functions in the Hyper API C++ library.
std::string toString() const
Returns a formatted string containing the message and hint of the error and all causes.
static SqlType smallInt() noexcept
Returns the SMALL INTEGER SQL type.
static SqlType bigInt() noexcept
Returns the BIG INTEGER SQL type.
static SqlType text() noexcept
Returns the TEXT SQL type.
static SqlType date() noexcept
Returns the DATE SQL type.
static SqlType doublePrecision() noexcept
Returns the DOUBLE PRECISION SQL type.
A Column of a table definition.
const TableName & getTableName() const noexcept
Returns the name of the table.
The main header of the Hyper API for C++.
@ NotNullable
The column cannot contain NULL values.
@ Nullable
The column can contain NULL values.
@ SendUsageDataToTableau
Telemetry data will be sent to tableau to help improve the Hyper API.
@ CreateAndReplace
Create the database. If it already exists, drop the old one first.