From e7f574039bfa0104e513549e36c6ef8aed5fe4e7 Mon Sep 17 00:00:00 2001 From: stephenstyffe Date: Fri, 26 Apr 2019 11:01:04 -0700 Subject: [PATCH] Added getAllPolls and getAllAnnouncements --- Infrastructure/Python/mysql_run.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Infrastructure/Python/mysql_run.py b/Infrastructure/Python/mysql_run.py index 9a83e05..9fd74b8 100644 --- a/Infrastructure/Python/mysql_run.py +++ b/Infrastructure/Python/mysql_run.py @@ -681,6 +681,7 @@ def postPollResponse(member_id, userResponse, group_id, poll_id): # for DELETE RESPONSE def deletePollResponse(response_id): + connection = pymysql.connect(host='35.185.248.192', user='Stephen', password='StephenSEProject', db='app_db', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor() @@ -697,6 +698,35 @@ def deletePollResponse(response_id): connection.close() return 0 +def getAllPolls(group_id): + connection = pymysql.connect(host='35.185.248.192', user='Stephen', password='StephenSEProject', db='app_db', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) + cursor = connection.cursor() + + selectStatement = "select * from `poll repository` where GroupID = %s" + + try: + cursor.execute(selectStatement, (group_id)) + result = cursor.fetchall() + connection.close() + return result + except: + connection.close() + return 0 + +def getAllAnnouncements(group_id): + connection = pymysql.connect(host='35.185.248.192', user='Stephen', password='StephenSEProject', db='app_db', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) + cursor = connection.cursor() + + selectStatement = "select * from `announcement` where GroupID = %s" + + try: + cursor.execute(selectStatement, (group_id)) + result = cursor.fetchall() + connection.close() + return result + except: + connection.close() + return 0 ###------------### ### END OF FILE - if this is missing, the file is truncated ### ###------------###