From 978bc38b2d333f704fceaa85e7899fdafe642f9b Mon Sep 17 00:00:00 2001 From: lshbluesky <61459016+lshbluesky@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:57:53 +0900 Subject: [PATCH] =?UTF-8?q?Edit=20account=5FDB.py;=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EA=B3=84=EC=A0=95=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20?= =?UTF-8?q?=EB=AA=A8=EB=91=90=20=EC=A1=B0=ED=9A=8C,=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=BF=BC=EB=A6=AC=20=EB=B0=8F=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account_DB.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/account_DB.py b/account_DB.py index e2e75f7..a17ae2a 100644 --- a/account_DB.py +++ b/account_DB.py @@ -1,7 +1,7 @@ """ CodeCraft PMS Project 파일명 : account_DB.py - 마지막 수정 날짜 : 2025/03/24 + 마지막 수정 날짜 : 2025/04/07 """ import pymysql @@ -352,3 +352,39 @@ def edit_user_pw(univ_id, pw): finally: cur.close() connection.close() + +# ------------------------------ 계정 정보 조회 및 수정 ------------------------------ # +# 사용자(학생)의 정보를 조회하는 함수 +# 학번을 매개 변수로 받는다 +def fetch_student_info(univ_id): + connection = db_connect() + cur = connection.cursor(pymysql.cursors.DictCursor) + + try: + cur.execute("SELECT * FROM student WHERE s_no = %s", (univ_id,)) + result = cur.fetchone() + return result + except Exception as e: + print(f"Error [fetch_student_info] : {e}") + return e + finally: + cur.close() + connection.close() + +# 사용자(학생)의 계정 정보를 수정하는 함수 +# 수정하려는 비밀번호, 이메일, 학과와 수정하려는 사용자(학생)의 학번을 매개 변수로 받는다 +def edit_student_info(pw, email, dno, univ_id): + connection = db_connect() + cur = connection.cursor(pymysql.cursors.DictCursor) + + try: + cur.execute("UPDATE student SET s_pw = %s, s_email = %s, dno = %s WHERE s_no = %s", (pw, email, dno, univ_id)) + connection.commit() + return True + except Exception as e: + connection.rollback() + print(f"Error [edit_student_info] : {e}") + return e + finally: + cur.close() + connection.close()