Open MagnusLii opened 10 months ago
The code takes int he topicID directly rather than a json string containing the data as handling that information within the function is pointless.
def get_topic(topicID):
try:
topic = Topics.query.filter_by(TopicID=topicID).first()
topic_data = {
"TopicID": topic.TopicID,
"Title": topic.Title,
"Description": topic.Description,
"StartTime": str(topic.StartTime),
"EndTime": str(topic.EndTime)
}
return jsonify(topic_data)
except Exception as errorMsg:
error_message = {"error": str(errorMsg)}
return jsonify(error_message), 500
Specific Vote Data Query Function from DB
Goal
This function takes in a JSON string containing the ID value of a vote within the database. Subsequently, the function constructs a SQL query to retrieve all information associated with the specified vote from the database.
Arguments
Returns
Function Name:
get_topic