Giter VIP home page Giter VIP logo

todo-app-cpp's Introduction

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.

Table of Contents

  1. Requirements
  2. Getting started with MariaDB
  3. Get the code
  4. Create the database and table
  5. Build and run the app
  6. Support and contribution
  7. License

Requirements

This sample was created using the following techologies and they must be installed before proceeding.

1.) Getting Started with MariaDB

MariaDB is a community-developed, commercially supported relational database management system, and the database you'll be using for this application.

If you don't have a MariaDB database up and running you can find more information on how to download, install and start using a MariaDB database in the MariaDB Quickstart Guide.

2.) Get the code

First, use git (through CLI or a client) to retrieve the code using git clone:

$ git clone https://github.com/mariadb-developers/todo-app-cpp.git

3.) Create the database and table

Connect to your MariaDB database (from Step #2) and execute the following SQL scripts using the following options:

a.) Use the MariaDB command-line client to execute the SQL contained within schema.sql.

Example command:

$ mariadb --host HOST_ADDRESS --port PORT_NO --user USER --password PASSWORD < schema.sql

schema OR

b.) Copy, paste and execute the raw SQL commands contained in schema.sql using a client of your choice.

CREATE DATABASE todo;

CREATE TABLE todo.tasks (
  id INT(11) unsigned NOT NULL AUTO_INCREMENT,
  description VARCHAR(500) NOT NULL,
  completed BOOLEAN NOT NULL DEFAULT 0,
  PRIMARY KEY (id)
);

4.) 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!"}});

5.) 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
    

Support and Contribution

Please feel free to submit PR's, issues or requests to this project project directly.

If you have any other questions, comments, or looking for more information on MariaDB please check out:

Or reach out to us diretly via:

License

License

todo-app-cpp's People

Contributors

rhedgpeth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.