From 29419540de3e44d65cbdf1020ee8c3c068d18800 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Sat, 4 Mar 2023 15:37:03 +0100 Subject: [PATCH] tried to return a participant --- src/server/BreCal/impl/participant.py | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/server/BreCal/impl/participant.py b/src/server/BreCal/impl/participant.py index 69f956f..1091ce5 100644 --- a/src/server/BreCal/impl/participant.py +++ b/src/server/BreCal/impl/participant.py @@ -1,5 +1,5 @@ import json - +import mariadb def GetParticipant(options): """ @@ -8,16 +8,26 @@ def GetParticipant(options): """ - # Implement your business logic here - # All the parameters are present in the options argument + conn = mariadb.connect(host="localhost", user="ds", password="kle1nes") - return json.dumps({ - "city": "", - "id": "", - "name": "", - "postal code": "", - "street": "", - }), 200 + cur = conn.cursor() + + query = "SELECT p.id, p.name, p.street, p.postal_code, p.city, p.flags FROM participant p INNER JOIN user u WHERE u.participant_id = p.id AND u.id = {id} " + + cur.execute(query) + + for (id, name, street, postal_code, city, flags) in cur: + + # Implement your business logic here + # All the parameters are present in the options argument + + return json.dumps({ + "city": city, + "id": id, + "name": name, + "postal code": postal_code, + "street": street, + }), 200