-
Notifications
You must be signed in to change notification settings - Fork 1
Working with the Database
To access data stored in the database, the VMSDatabase class can be used.
The class was made to speed up development by simplifying database connection. It uses the Sqlite3 library.
Warning: Ensure you link libsqlite3 in the linker or the build will fail.
An instance of this class is already initialised at the top of the main.cpp file. (VMSDatabase VMSDatabase;)
| 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") |
❌ |
The table parameter is made easy with a set of short options for each table. It is passed as a single word string.
-
pets- Pet Management -
owners- Owner Management -
appointments- Appointment Management -
staff- Staff Management
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
This function can be used to quickly display the contents of a database table to the user. It's not as well formatted as I'd like but it works.
Example: VMSDatabase.printTable("owners");
Explanation: Print a table of the data from Owner Management to the console.
Result: [table]
By Luke Pring and Jack Turner for the Software Development 2 module at University of Roehampton, London.