An example of how to create and insert into a single-table Hyper file with different column types.
#include <iostream>
#include <string>
#include <unordered_set>
{"Extract", "Extract"},
static void runInsertDataIntoSingleTable() {
std::cout << "EXAMPLE - Insert data into a single table within a new Hyper file" << std::endl;
const std::string pathToDatabase = "data/customer.hyper";
{
{
catalog.createTable(extractTable);
{
inserter.addRow("DK-13375", "Dennis Kane", 518, "Consumer");
inserter.addRow("EB-13705", "Ed Braxton", 815, "Corporate");
inserter.execute();
}
std::unordered_set<hyperapi::TableName> tableNames = catalog.getTableNames("Extract");
std::cout << "Tables available in " << pathToDatabase << " in the Extract schema are: ";
for (auto& tableName : tableNames)
std::cout << tableName.toString() << "\t";
std::cout << std::endl;
int64_t rowCount = connection.executeScalarQuery<int64_t>("SELECT COUNT(*) FROM " + extractTable.getTableName().toString());
std::cout << "The number of rows in table " << extractTable.getTableName() << " is " << rowCount << "." << std::endl;
}
std::cout << "The connection to the Hyper file has been closed." << std::endl;
}
std::cout << "The Hyper Process has been shut down." << std::endl;
}
int main() {
try {
runInsertDataIntoSingleTable();
return 1;
}
return 0;
}