Open Micah456 opened 1 month ago
8/7/2024: finished the functions, getting user object by id is returning none even though I can see it calling the correct sql statements and getting the right data. Need to look into how objects are constructed within the python code.
Function to get an object or row in the database
[x] Create the function to get the data from the database: e.g. get_object Takes 3 arguments: object table, object ID (optional), parent ID (optional). Execute select statements. If ID provided you specify the ID and call the function to create an object dict of that type. If no ID, you create a list of object dicts for all rows returned and return that. Parent ID can be included in the latter. A switch statement can be used to choose which create_dict function (see below) will be used, based on the object table parameter.
[x] Create function to create a user dict: Add all the row data to the dict, Then create another key 'Routines' and call the get_object function using the Routine Table and the users ID as the parent ID. This will create a List of routine dicts that belong to the user.
[x] Create function to create a routine dict: As with above but create a key with the name 'Steps' and call get_object using the Step table and the routine ID as the parent ID to create a list of step dicts that belong to the routine
[x] Create function to create a step dict: Add all row data to the dict.
[ ] Test all of these