create_table
Function: add_table
add_tableDeclaration
operation add_table(std::string name, std::unordered_map<std::string, data_type> content);Parameters
#include "qic.h"
#include <iostream>
#include <unordered_map>
int main() {
data_base db;
// Open the database
db.open_database("mydatabase.db");
// Define the table schema
std::unordered_map<std::string, data_type> schema = {
{"id", INT},
{"name", STRING},
{"active", BOOL},
{"balance", DOUBLE}
};
// Add a new table named "users"
operation op = db.add_table("users", schema);
// Check if the operation was successful
if (op.stat == SUCCESS) {
std::cout << "Table 'users' created successfully!" << std::endl;
} else {
std::cout << "Failed to create table: " << op.error << std::endl;
}
// Close the database
db.close();
return 0;
}Last updated