Files
2021-01-28 13:58:31 -06:00

1.5 KiB

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!

  1. Build tasks.cpp to produce an executable called tasks.
$ g++ -o tasks tasks.cpp -std=c++11 -lmariadbcpp
  1. Perform CRUD operations using the tasks executable.

    a. Insert a new task record.

    $ ./tasks addTask 'New Task Description'
    

    b. Update a task's completion status.

    $ ./tasks updateTaskStatus 1 1
    

    c. Select and print all tasks.

    $ ./tasks showTasks
    

    d. Delete a task record.

    $ ./tasks deleteTask 1