Skip to content

Working with the Database

Luke Pring edited this page Mar 19, 2025 · 12 revisions

To access data stored in the database, the VMSDatabase class.

An instance of this class is already initialised at the top of the main.cpp file. (VMSDatabase VMSDatabase;)

Functions

Function Name Example Available
getData(table) VMSDatabase.getData("pets");
printTable(table) VMSDatabase.printTable("pets");
addRecord(table, data) VMSDatabase.addRecord("pets", {"Bob", "Pug", "3", "Has asthma", "1", "1"});
deleteRecord(table, id) VMSDatabase.deleteRecord("pets", "1")

Table parameter

The table parameter is made easy with a set of short options for each table. It is passed as a single word string.

Valid strings

  • pets - Pet Management
  • owners - Owner Management
  • appointments - Appointment Management
  • staff - Staff Management

getData

This function is used to retrieve data from the database.

The data is returned as a <vector>. A single value from the table can be referenced simply.


Example: std::cout << VMSDatabase.getData("pets")[0][1];

Explanation: Print the second value (Pet Name) from the first record in the Pet Management table.

Result: Bob

Clone this wiki locally