mirror of
https://github.com/mariadb-corporation/dev-example-todo.git
synced 2026-01-11 10:03:10 +00:00
TODO - C++ Console Application
The tasks.cpp file can be used (via C++ compiler) to build an executable that can perform create-read-update-delete (CRUD) operations on a target MariaDB database using MariaDB's C++ connector.
Requirements
This sample was created using the following techologies and they must be installed before proceeding.
Configure the code
Within the tasks.cpp file, navigate to the main method and add your database connection values.
Example implementation:
sql::SQLString url("jdbc:mariadb://localhost:3306/todo");
sql::Properties properties({{"user", "app_user"}, {"password", "Password123!"}});
Run the app
Once you've pulled down and configured the code, you're ready to build and run the application!
- Build tasks.cpp to produce an executable called
tasks.
$ g++ -o tasks tasks.cpp -std=c++11 -lmariadbcpp
-
Perform CRUD operations using the
tasksexecutable.a. Insert a new task record.
$ ./tasks addTask 'New Task Description'b. Update a task's completion status.
$ ./tasks updateTaskStatus 1 1c. Select and print all tasks.
$ ./tasks showTasksd. Delete a task record.
$ ./tasks deleteTask 1