我们提供迎新管理系统招投标所需全套资料,包括迎新系统介绍PPT、迎新管理系统产品解决方案、
迎新系统产品技术参数,以及对应的标书参考文件,详请联系客服。
class Student: def __init__(self, name, id, major): self.name = name self.id = id self.major = major ]]>
CREATE TABLE students ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), student_id VARCHAR(20) UNIQUE, major VARCHAR(50) ); ]]>
import pymysql def add_student(student): connection = pymysql.connect(host='localhost', user='root', password='password', database='school') try: with connection.cursor() as cursor: sql = "INSERT INTO students (name, student_id, major) VALUES (%s, %s, %s)" cursor.execute(sql, (student.name, student.id, student.major)) connection.commit() finally: connection.close() ]]>
def find_student_by_id(student_id): connection = pymysql.connect(host='localhost', user='root', password='password', database='school') try: with connection.cursor() as cursor: sql = "SELECT * FROM students WHERE student_id=%s" cursor.execute(sql, (student_id,)) result = cursor.fetchone() return result finally: connection.close() ]]>
Copyright © 迎新系统