In the student information management system, firstly, the administrator will add, delete, modify, search and import teacher information, and then the teacher interface will log in to different teacher categories. The counselor teacher is responsible for adding, deleting and searching the relevant information of students, the educational administration teacher is responsible for adding, deleting, modifying and searching the relevant information of which courses, and the teaching teacher is responsible for adding, deleting Modify, search and the scores of students in this course. Students add the information to the database through registration, and then log in. Students can check their grades, query and modify their personal information through this system, and query the curriculum arrangement of their class.
Project significance
(1) Ensure the accuracy and timeliness of information, manage the system through the computer at any time, keep the student information in the latest state, and ensure the accuracy of statistical data and analysis.
(2) Reduce labor intensity, improve work efficiency and increase the transparency of student management. College student management information system can give full play to the powerful function of computer, liberate managers from a large number of cumbersome manual labor, and turn monotonous paper scribbling into flexible electronic information operation. And make full use of the advantages of the network to speed up the release, transmission and acquisition of student information and documents within the school, improve and optimize student work, make the work contact between various departments close, orderly and clear, greatly reduce the work burden, improve work efficiency and increase the transparency of student management.
(3) Reduce the management cost. Due to the use of this system, the counselor management has changed the passive situation buried in various forms in the past, basically realized paperless office, eradicated a lot of waste in daily management, and reflected the advantages of modern student management.
(4) Standardized management, due to the use of computer statistics and analysis of student information, some original information must be accurately entered when entering, which requires managers to be accurate when providing information and be very careful when entering. This is to minimize errors and improve the accuracy of system work, So as to realize the standardization of student management.
Database introduction:
MySQL is a DBMS and a small open source relational database management system. MySQL AB was acquired by sun on January 16, 2008. In 2009, sun was acquired by Oracle. In this way, like a reincarnation, MySQL has become another database project of Oracle.
MySQL has been widely installed and used all over the world. It should be the database software with the largest number of users because it has such characteristics:
Cost - MySQL is open source software that can be used and modified free of charge.
Performance - MySQL has good performance and fast processing speed.
Simple - MySQL is easy to install and use and is friendly to novices.
MySQL database software also uses the most commonly used database management language: Structured Query Language (SQL) for database management and operation.
**
How does python use sql statement to realize the addition, deletion, modification and query of mysql database?
**
Here, pymysql is used to operate Mysql to add, delete, change and query student data. Pymysql is a MySQL client operation library implemented in pure Python
class StudentManager(object): def __init__(self): # Store student data - List self.student_list = [] # I Program entry function def run(self): # 1. Load the student data in the file self.load_student() def save(): # print("start timer") self.save_student() timer = threading.Timer(1, function=save) # Re create the timer so that the timer can work all the time timer.start() # Start timer t1 = threading.Timer(1, function=save) # Create timer t1.start() # Start timer while True: # 2. Display function menu self.show_menu() # 3. The user inputs the target function serial number menu_num = int(input('Please enter the function serial number you need:')) # 4. Perform different functions according to the serial number entered by the user -- if the user enters 1, perform addition if menu_num == 1: # Add student self.add_student() elif menu_num == 2: # Delete student self.del_student() elif menu_num == 3: # Modify student information self.modify_student() elif menu_num == 4: # Query student information self.search_student() elif menu_num == 5: # Display all student information self.show_student() elif menu_num == 6: # Save student information self.save_student() elif menu_num == 7: t1.cancel() # Cancel timer # Exit system -- exit loop break
Database connection function:
def datac(self):#Connect to database db = pymysql.connect(host='localhost', user='root', password='456566546', database='lijin' )
python_sql execution statement:
cur.execute("DROP TABLE IF EXISTS Student") # Execute SQL statement sqlQuery = "CREATE TABLE Student(Name CHAR(20) NOT NULL ,Gender CHAR(20),Tel CHAR(20))" cur.execute(sqlQuery) # Execute SQL statement
Data storage timer function:
def save(): # print("start timer") self.save_student() timer = threading.Timer(1, function=save) # Re create the timer so that the timer can work all the time timer.start() # Start timer t1 = threading.Timer(1, function=save) # Create timer t1.start() # Start timer
Save local list data to database statement:
for a in new_list: sqlQuery = "INSERT INTO Student(Name, Gender, Tel) VALUE (%s, %s, %s)" value = (a['name'], a['gender'], a['tel']) cur.execute(sqlQuery, value) db.commit() db.close()
Errors or bug s may occur during the operation of the system. At this time, we also need to use the try function in python
Exception:
When the program is running, if the python interpreter encounters an error, it will stop the execution of the program,
And prompt some error messages, which is an exception
When we develop programs, it is difficult to deal with all special cases,
Through exception capture, you can
Emergencies are handled centrally, so as to ensure the robustness and stability of the program
In program development, if the execution of some code is uncertain (the program syntax is completely correct)
try can be added to catch exceptions
try this keyword to catch exceptions
try: the code you are trying to execute
Exception: handling of errors
try: # Unable to determine correctly executed code num = int(input('Please enter a number:')) except: print('Please enter the correct integer') print('*' * 50)