Open MagnusLii opened 10 months ago
Instead of a json containing the userID and espID the function takes in each of these as separate arguments.
def create_user(username, deviceID):
try:
user = Users(Username=username, DeviceIndex=deviceID)
db.session.add(user)
db.session.commit()
return True, "User created successfully."
except Exception as errorMsg:
return False, str(errorMsg)
User and ESP Data Registration Function
Goal
The objective is to create a function that, upon prompt from the website, processes a JSON string containing ESP ID and optionally Username. This function transforms the JSON string into an SQL query and sends it to the database for execution.
Arguments
Returns
Function Name:
create_user