Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql
- connection = pymysql.connect(host='localhost', user='root', password='', db='uni', cursorclass=pymysql.cursors.DictCursor)
- def search_database():
- with connection.cursor() as cursor:
- cursor.execute("SELECT * FROM `student`")
- results = cursor.fetchall()
- return results
- def add_student(student_name, student_email, course_id):
- with connection.cursor() as cursor:
- cursor.execute(f'INSERT INTO student (student_name, student_email, courseid) VALUES ("{student_name}","{student_email}",{course_id})')
- connection.commit()
- print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement