getReservations modified
- return parametes changed - reservations_id, user_id, facility_id, start_time, end_time - => reservations_id, user_id, facility_id, location, location_detail, capacity, start_time, end_time
Showing
1 changed file
with
5 additions
and
4 deletions
... | @@ -24,7 +24,9 @@ import datetime | ... | @@ -24,7 +24,9 @@ import datetime |
24 | # input: | 24 | # input: |
25 | # string user_id | 25 | # string user_id |
26 | # output: | 26 | # output: |
27 | - # 성공시 : tuple형태로 반환 => ( (1 ,"steven123", 7, datetime.datetime(2018,12,5,12,0,0), datetime.datetime(2018,12,5,12,10,0), ), ) | 27 | + # 성공시 : tuple형태로 반환 => ( (1 ,"steven123", 7, "전자정보대학", "136호", 10, datetime.datetime(2018,12,5,12,0,0), datetime.datetime(2018,12,5,12,10,0), ), ) |
28 | + # 순서 : reservations_id, user_id, facility_id, location, location_detail, capacity, start_time, end_time | ||
29 | + | ||
28 | # 실패시 : tuple형태로 반환 => ( ("SQL Error!", ), ) | 30 | # 실패시 : tuple형태로 반환 => ( ("SQL Error!", ), ) |
29 | # 사용예: | 31 | # 사용예: |
30 | # result = getReservations("khucse123") | 32 | # result = getReservations("khucse123") |
... | @@ -35,7 +37,8 @@ def getReservations(user_id): | ... | @@ -35,7 +37,8 @@ def getReservations(user_id): |
35 | db = pymysql.connect(host='1.201.139.92', port=3306, user=user_info.user_id, password=user_info.user_passwd, db='FRS', charset='utf8') | 37 | db = pymysql.connect(host='1.201.139.92', port=3306, user=user_info.user_id, password=user_info.user_passwd, db='FRS', charset='utf8') |
36 | curs = db.cursor() | 38 | curs = db.cursor() |
37 | 39 | ||
38 | - curs.execute("select * from reservations where user_id=%s", user_id) | 40 | + #curs.execute("select * from reservations where user_id=%s", user_id) |
41 | + curs.execute("select r.reservations_id, r.user_id, r.facility_id, f.location, f.location_detail, f.capacity, r.start_time, r.end_time from reservations r, facilities f where r.user_id=%s AND r.facility_id=f.facility_id;", user_id) | ||
39 | result = curs.fetchall() | 42 | result = curs.fetchall() |
40 | print("Fetch Success!") | 43 | print("Fetch Success!") |
41 | return result | 44 | return result |
... | @@ -108,5 +111,3 @@ def addReservations(user_id, facility_id, start_time, end_time): | ... | @@ -108,5 +111,3 @@ def addReservations(user_id, facility_id, start_time, end_time): |
108 | finally: | 111 | finally: |
109 | db.close() | 112 | db.close() |
110 | 113 | ||
111 | - | ||
112 | - | ... | ... |
-
Please register or login to post a comment