added creating teacher functionality

This commit is contained in:
Hosein
2025-12-30 20:47:37 +03:30
parent a52d62c0fc
commit af88cbce8f
4 changed files with 123 additions and 5 deletions
+25 -1
View File
@@ -77,7 +77,7 @@ class Teachers:
cursor = conn.cursor()
cursor.execute(
"SELECT id,username, name, created_at, email, phone_number, last_seen, is_verfied, birthday, about_me, job_title FROM teachers WHERE id = %s", (teacher_id))
"SELECT id, username, name, created_at, email, phone_number, last_seen, is_verfied, birthday, about_me, job_title FROM teachers WHERE id = %s", (teacher_id, ))
result = cursor.fetchall()
cursor.close()
@@ -88,3 +88,27 @@ class Teachers:
finally:
if conn:
connection.release_db_connection(conn)
def createTeacher(name, email, phone_number, password, username, birthday, about_me, job_title):
conn = None
try:
conn = connection.get_db_connection()
if not conn:
return False
cursor = conn.cursor()
cursor.execute(
"INSERT INTO teachers (name, email, phone_number, hashed_password, username, birthday, about_me, job_title) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
(name, email, phone_number, password,
username, birthday, about_me, job_title)
)
conn.commit()
cursor.close()
return True
except Exception as e:
logger.error(f"Database query error in createTeacher: {e}")
return False
finally:
if conn:
connection.release_db_connection(conn)