15static void copy(
const std::string& sourcePath,
const std::string& destinationPath) {
16 std::ifstream source(sourcePath, std::ios::binary);
17 std::ofstream destination(destinationPath, std::ios::binary);
18 destination << source.rdbuf();
23static void runUpdateDataInExistingHyperFile() {
24 std::cout <<
"EXAMPLE - Update existing data in a Hyper file" << std::endl;
28 const std::string pathToSourceDatabase =
"data/superstore_sample.hyper";
31 const std::string pathToDatabase =
"data/superstore_sample_update.hyper";
32 copy(pathToSourceDatabase, pathToDatabase);
45 std::cout <<
"Pre-Update: Individual rows showing 'Loyalty Reward Points' and 'Segment' columns: " << std::endl;
48 std::cout << value <<
'\t';
52 std::cout << std::endl;
54 std::cout <<
"Update 'Customers' table by adding 50 Loyalty Reward Points to all Corporate Customers." << std::endl;
55 int64_t rowCount = connection.executeCommand(
60 std::cout <<
"The number of updated rows in table " <<
hyperapi::escapeName(
"Customer") <<
" is " << rowCount <<
"." << std::endl;
66 std::cout << value <<
'\t';
71 std::cout <<
"The connection to the Hyper file has been closed." << std::endl;
73 std::cout <<
"The Hyper Process has been shut down." << std::endl;
78 runUpdateDataInExistingHyperFile();
80 std::cout << e.
toString() << std::endl;
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.
Base class for a result of a query.
The main header of the Hyper API for C++.
@ SendUsageDataToTableau
Telemetry data will be sent to tableau to help improve the Hyper API.
std::string escapeName(string_view input)
Escapes the given string for safe usage in SQL query or command strings as an identifier.
std::string escapeStringLiteral(string_view input)
Escapes the given string for safe usage in SQL query or command strings as a string literal.