Python題目:學生信息管理系統-高級版(圖形界面+MySQL數據庫)

Python題目:學生信息管理系統-高級版(圖形界面+MySQL數據庫)

       使用圖形界面顯示,選用list、tuple、dictionary或map等數據結構,操作數據庫存儲X個學生的三門課的成績(機器學習、Python程序設計、研究生英語),並實現以下功能:

1.添加學生信息
2.修改學生信息
3.刪除學生
4.添加學生的成績
5.修改學生成績
6.按姓名或者學號查找學生,顯示學生信息及三門課的成績,以及排名
7.學生成績統計(每門課的平均分、最高分、最低分)

代碼裏的註釋很清楚了,這裏不做講解了,有任何問題可以評論提問。 

注意:

  • 數據表不存在則創建表,但自動創建的表是空白的,管理員用戶名和密碼需要自己數據庫中添加一個(也可以運行文章最後的sql語句),爲什麼會出現這個問題,因爲這是個課堂作業,當時沒有設計好,現在懶得再改代碼了╮(╯﹏╰)╭.......
  • 數據庫在代碼中(代碼裏有兩處需要修改數據庫 用戶名、密碼 的地方第66行第490行),配置爲:
# 打開數據庫連接 連接測試
db = pymysql.connect("localhost", "root", "root", "student")

       分別表示  主機名:localhost,用戶名:root,密碼:root,數據庫名:student 


下面是界面的截圖

 

 管理員操作界面,擁有增刪改查功能,甚至擁有排序功能φ(>ω<*) ,快點擊標籤欄試試

 

 代碼:

#!/usr/bin/python3

import pymysql
from tkinter import ttk
import tkinter as tk
import tkinter.font as tkFont
from tkinter import * # 圖形界面庫
import tkinter.messagebox as messagebox # 彈窗


class StartPage:
	def __init__(self, parent_window):
		parent_window.destroy() # 銷燬子界面

		self.window = tk.Tk()  # 初始框的聲明
		self.window.title('學生信息管理系統')
		self.window.geometry('300x470') # 這裏的乘是小x

		label = Label(self.window, text="學生信息管理系統", font=("Verdana", 20))
		label.pack(pady=100)  # pady=100 界面的長度

		Button(self.window, text="管理員登陸", font=tkFont.Font(size=16), command=lambda: AdminPage(self.window), width=30, height=2,
			   fg='white', bg='gray', activebackground='black', activeforeground='white').pack()
		Button(self.window, text="學生登陸", font=tkFont.Font(size=16), command=lambda: StudentPage(self.window), width=30,
			   height=2,fg='white', bg='gray', activebackground='black', activeforeground='white').pack()
		Button(self.window, text="關於", font=tkFont.Font(size=16), command=lambda: AboutPage(self.window), width=30, height=2,
			   fg='white', bg='gray', activebackground='black', activeforeground='white').pack()
		Button(self.window, text='退出系統', height=2, font=tkFont.Font(size=16), width=30, command=self.window.destroy,
			   fg='white', bg='gray', activebackground='black', activeforeground='white').pack()

		self.window.mainloop() # 主消息循環


#管理員登陸頁面
class AdminPage:
	def __init__(self, parent_window):
		parent_window.destroy() # 銷燬主界面

		self.window = tk.Tk()  # 初始框的聲明
		self.window.title('管理員登陸頁面')
		self.window.geometry('300x450')  # 這裏的乘是小x

		label = tk.Label(self.window, text='管理員登陸', bg='green', font=('Verdana', 20), width=30, height=2)
		label.pack()

		Label(self.window, text='管理員賬號:', font=tkFont.Font(size=14)).pack(pady=25)
		self.admin_username = tk.Entry(self.window, width=30, font=tkFont.Font(size=14), bg='Ivory')
		self.admin_username.pack()

		Label(self.window, text='管理員密碼:', font=tkFont.Font(size=14)).pack(pady=25)
		self.admin_pass = tk.Entry(self.window, width=30, font=tkFont.Font(size=14), bg='Ivory', show='*')
		self.admin_pass.pack()

		Button(self.window, text="登陸", width=8, font=tkFont.Font(size=12), command=self.login).pack(pady=40)
		Button(self.window, text="返回首頁", width=8, font=tkFont.Font(size=12), command=self.back).pack()

		self.window.protocol("WM_DELETE_WINDOW", self.back)  # 捕捉右上角關閉點擊
		self.window.mainloop()  # 進入消息循環

	def login(self):
		print(str(self.admin_username.get()))
		print(str(self.admin_pass.get()))
		admin_pass = None

		# 數據庫操作 查詢管理員表
		db = pymysql.connect("localhost", "root", "root", "student")  # 打開數據庫連接
		cursor = db.cursor()  # 使用cursor()方法獲取操作遊標
		sql = "SELECT * FROM admin_login_k WHERE admin_id = '%s'" % (self.admin_username.get())  # SQL 查詢語句
		try:
		# 執行SQL語句
			cursor.execute(sql)
			# 獲取所有記錄列表
			results = cursor.fetchall()
			for row in results:
				admin_id = row[0]
				admin_pass = row[1]
				# 打印結果
				print("admin_id=%s,admin_pass=%s" % (admin_id, admin_pass))
		except:
			print("Error: unable to fecth data")
			messagebox.showinfo('警告!', '用戶名或密碼不正確!')
		db.close()  # 關閉數據庫連接

		print("正在登陸管理員管理界面")
		print("self",self.admin_pass)
		print("local",admin_pass)

		if self.admin_pass.get() == admin_pass:
			AdminManage(self.window)  # 進入管理員操作界面
		else:
			messagebox.showinfo('警告!', '用戶名或密碼不正確!')

	def back(self):
		StartPage(self.window) # 顯示主窗口 銷燬本窗口


#學生登陸頁面
class StudentPage:
	def __init__(self, parent_window):
		parent_window.destroy() # 銷燬主界面

		self.window = tk.Tk()  # 初始框的聲明
		self.window.title('學生登陸')
		self.window.geometry('300x450')  # 這裏的乘是小x

		label = tk.Label(self.window, text='學生登陸', bg='green', font=('Verdana', 20), width=30, height=2)
		label.pack()

		Label(self.window, text='學生賬號:', font=tkFont.Font(size=14)).pack(pady=25)
		self.student_id = tk.Entry(self.window, width=30, font=tkFont.Font(size=14), bg='Ivory')
		self.student_id.pack()

		Label(self.window, text='學生密碼:', font=tkFont.Font(size=14)).pack(pady=25)
		self.student_pass = tk.Entry(self.window, width=30, font=tkFont.Font(size=14), bg='Ivory', show='*')
		self.student_pass.pack()

		Button(self.window, text="登陸", width=8, font=tkFont.Font(size=12), command=self.login).pack(pady=40)
		Button(self.window, text="返回首頁", width=8, font=tkFont.Font(size=12), command=self.back).pack()

		self.window.protocol("WM_DELETE_WINDOW", self.back)  # 捕捉右上角關閉點擊
		self.window.mainloop()  # 進入消息循環

	def login(self):
		print(str(self.student_id.get()))
		print(str(self.student_pass.get()))
		stu_pass = None

		# 數據庫操作 查詢管理員表
		db = pymysql.connect("localhost", "root", "root", "student")  # 打開數據庫連接
		cursor = db.cursor()  # 使用cursor()方法獲取操作遊標
		sql = "SELECT * FROM stu_login_k WHERE stu_id = '%s'" % (self.student_id.get())  # SQL 查詢語句
		try:
			# 執行SQL語句
			cursor.execute(sql)
			# 獲取所有記錄列表
			results = cursor.fetchall()
			for row in results:
				stu_id = row[0]
				stu_pass = row[1]
				# 打印結果
				print("stu_id=%s,stu_pass=%s" % (stu_id, stu_pass))
		except:
			print("Error: unable to fecth data")
			messagebox.showinfo('警告!', '用戶名或密碼不正確!')
		db.close()  # 關閉數據庫連接

		print("正在登陸學生信息查看界面")
		print("self", self.student_pass.get())
		print("local", stu_pass)

		if self.student_pass.get() == stu_pass:
			StudentView(self.window, self.student_id.get()) # 進入學生信息查看界面
		else:
			messagebox.showinfo('警告!', '用戶名或密碼不正確!')

	def back(self):
		StartPage(self.window)  # 顯示主窗口 銷燬本窗口



# 管理員操作界面
class AdminManage:
	def __init__(self, parent_window):
		parent_window.destroy() # 銷燬主界面

		self.window = Tk()  # 初始框的聲明
		self.window.title('管理員操作界面')

		self.frame_left_top = tk.Frame(width=300, height=200)
		self.frame_right_top = tk.Frame(width=200, height=200)
		self.frame_center = tk.Frame(width=500, height=400)
		self.frame_bottom = tk.Frame(width=650, height=50)

		# 定義下方中心列表區域
		self.columns = ("學號", "姓名", "性別", "年齡")
		self.tree = ttk.Treeview(self.frame_center, show="headings", height=18, columns=self.columns)
		self.vbar = ttk.Scrollbar(self.frame_center, orient=VERTICAL, command=self.tree.yview)
		# 定義樹形結構與滾動條
		self.tree.configure(yscrollcommand=self.vbar.set)

		# 表格的標題
		self.tree.column("學號", width=150, anchor='center')  # 表示列,不顯示
		self.tree.column("姓名", width=150, anchor='center')
		self.tree.column("性別", width=100, anchor='center')
		self.tree.column("年齡", width=100, anchor='center')

		# 調用方法獲取表格內容插入
		self.tree.grid(row=0, column=0, sticky=NSEW)
		self.vbar.grid(row=0, column=1, sticky=NS)

		self.id = []
		self.name = []
		self.gender = []
		self.age = []
		# 打開數據庫連接
		db = pymysql.connect("localhost", "root", "root", "student")
		cursor = db.cursor()  # 使用cursor()方法獲取操作遊標
		sql = "SELECT * FROM student_k"  # SQL 查詢語句
		try:
			# 執行SQL語句
			cursor.execute(sql)
			# 獲取所有記錄列表
			results = cursor.fetchall()
			for row in results:
				self.id.append(row[0])
				self.name.append(row[1])
				self.gender.append(row[2])
				self.age.append(row[3])
				# print(self.id)
				# print(self.name)
				# print(self.gender)
				# print(self.age)
		except:
			print("Error: unable to fetch data")
			messagebox.showinfo('警告!', '數據庫連接失敗!')
		db.close()# 關閉數據庫連接


		print("test***********************")
		for i in range(min(len(self.id), len(self.name), len(self.gender), len(self.age))):  # 寫入數據
			self.tree.insert('', i, values=(self.id[i], self.name[i], self.gender[i], self.age[i]))

		for col in self.columns:  # 綁定函數,使表頭可排序
			self.tree.heading(col, text=col,
							  command=lambda _col=col: self.tree_sort_column(self.tree, _col, False))

		# 定義頂部區域
		# 定義左上方區域
		self.top_title = Label(self.frame_left_top, text="學生信息:", font=('Verdana', 20))
		self.top_title.grid(row=0, column=0, columnspan=2, sticky=NSEW, padx=50, pady=10)

		self.left_top_frame = tk.Frame(self.frame_left_top)
		self.var_id = StringVar()  # 聲明學號
		self.var_name = StringVar()  # 聲明姓名
		self.var_gender = StringVar()  # 聲明性別
		self.var_age = StringVar()  # 聲明年齡
		# 學號
		self.right_top_id_label = Label(self.frame_left_top, text="學號:", font=('Verdana', 15))
		self.right_top_id_entry = Entry(self.frame_left_top, textvariable=self.var_id, font=('Verdana', 15))
		self.right_top_id_label.grid(row=1, column=0)  # 位置設置
		self.right_top_id_entry.grid(row=1, column=1)
		# 姓名
		self.right_top_name_label = Label(self.frame_left_top, text="姓名:", font=('Verdana', 15))
		self.right_top_name_entry = Entry(self.frame_left_top, textvariable=self.var_name, font=('Verdana', 15))
		self.right_top_name_label.grid(row=2, column=0)  # 位置設置
		self.right_top_name_entry.grid(row=2, column=1)
		# 性別
		self.right_top_gender_label = Label(self.frame_left_top, text="性別:", font=('Verdana', 15))
		self.right_top_gender_entry = Entry(self.frame_left_top, textvariable=self.var_gender,
											font=('Verdana', 15))
		self.right_top_gender_label.grid(row=3, column=0)  # 位置設置
		self.right_top_gender_entry.grid(row=3, column=1)
		# 年齡
		self.right_top_gender_label = Label(self.frame_left_top, text="年齡:", font=('Verdana', 15))
		self.right_top_gender_entry = Entry(self.frame_left_top, textvariable=self.var_age,
											font=('Verdana', 15))
		self.right_top_gender_label.grid(row=4, column=0)  # 位置設置
		self.right_top_gender_entry.grid(row=4, column=1)

		# 定義右上方區域
		self.right_top_title = Label(self.frame_right_top, text="操作:", font=('Verdana', 20))

		self.tree.bind('<Button-1>', self.click)  # 左鍵獲取位置
		self.right_top_button1 = ttk.Button(self.frame_right_top, text='新建學生信息', width=20, command=self.new_row)
		self.right_top_button2 = ttk.Button(self.frame_right_top, text='更新選中學生信息', width=20,
											command=self.updata_row)
		self.right_top_button3 = ttk.Button(self.frame_right_top, text='刪除選中學生信息', width=20,
											command=self.del_row)

		# 位置設置
		self.right_top_title.grid(row=1, column=0, pady=10)
		self.right_top_button1.grid(row=2, column=0, padx=20, pady=10)
		self.right_top_button2.grid(row=3, column=0, padx=20, pady=10)
		self.right_top_button3.grid(row=4, column=0, padx=20, pady=10)

		# 整體區域定位
		self.frame_left_top.grid(row=0, column=0, padx=2, pady=5)
		self.frame_right_top.grid(row=0, column=1, padx=30, pady=30)
		self.frame_center.grid(row=1, column=0, columnspan=2, padx=4, pady=5)
		self.frame_bottom.grid(row=2, column=0, columnspan=2)

		self.frame_left_top.grid_propagate(0)
		self.frame_right_top.grid_propagate(0)
		self.frame_center.grid_propagate(0)
		self.frame_bottom.grid_propagate(0)

		self.frame_left_top.tkraise() # 開始顯示主菜單
		self.frame_right_top.tkraise() # 開始顯示主菜單
		self.frame_center.tkraise() # 開始顯示主菜單
		self.frame_bottom.tkraise() # 開始顯示主菜單

		self.window.protocol("WM_DELETE_WINDOW", self.back)  # 捕捉右上角關閉點擊
		self.window.mainloop()  # 進入消息循環

	def back(self):
		StartPage(self.window) # 顯示主窗口 銷燬本窗口

	def click(self, event):
		self.col = self.tree.identify_column(event.x)  # 列
		self.row = self.tree.identify_row(event.y)  # 行

		print(self.col)
		print(self.row)
		self.row_info = self.tree.item(self.row, "values")
		self.var_id.set(self.row_info[0])
		self.var_name.set(self.row_info[1])
		self.var_gender.set(self.row_info[2])
		self.var_age.set(self.row_info[3])
		self.right_top_id_entry = Entry(self.frame_left_top, state='disabled', textvariable=self.var_id,
										font=('Verdana', 15))

		print('')

	def tree_sort_column(self, tv, col, reverse):  # Treeview、列名、排列方式
		l = [(tv.set(k, col), k) for k in tv.get_children('')]
		l.sort(reverse=reverse)  # 排序方式
		# rearrange items in sorted positions
		for index, (val, k) in enumerate(l):  # 根據排序後索引移動
			tv.move(k, '', index)
		tv.heading(col, command=lambda: self.tree_sort_column(tv, col, not reverse))  # 重寫標題,使之成爲再點倒序的標題

	def new_row(self):
		print('123')
		print(self.var_id.get())
		print(self.id)
		if str(self.var_id.get()) in self.id:
			messagebox.showinfo('警告!', '該學生已存在!')
		else:
			if self.var_id.get() != '' and self.var_name.get() != '' and self.var_gender.get() != '' and self.var_age.get() != '':
				# 打開數據庫連接
				db = pymysql.connect("localhost", "root", "root", "student")
				cursor = db.cursor()  # 使用cursor()方法獲取操作遊標
				sql = "INSERT INTO student_k(id, name, gender, age) \
				       VALUES ('%s', '%s', '%s', '%s')" % \
					  (self.var_id.get(), self.var_name.get(), self.var_gender.get(), self.var_age.get())  # SQL 插入語句
				try:
					cursor.execute(sql)  # 執行sql語句
					db.commit()  # 提交到數據庫執行
				except:
					db.rollback()  # 發生錯誤時回滾
					messagebox.showinfo('警告!', '數據庫連接失敗!')
				db.close()  # 關閉數據庫連接

				self.id.append(self.var_id.get())
				self.name.append(self.var_name.get())
				self.gender.append(self.var_gender.get())
				self.age.append(self.var_age.get())
				self.tree.insert('', len(self.id) - 1, values=(
				self.id[len(self.id) - 1], self.name[len(self.id) - 1], self.gender[len(self.id) - 1],
				self.age[len(self.id) - 1]))
				self.tree.update()
				messagebox.showinfo('提示!', '插入成功!')
			else:
				messagebox.showinfo('警告!', '請填寫學生數據')

	def updata_row(self):
		res = messagebox.askyesnocancel('警告!', '是否更新所填數據?')
		if res == True:
			if self.var_id.get() == self.row_info[0]:  # 如果所填學號 與 所選學號一致
				# 打開數據庫連接
				db = pymysql.connect("localhost", "root", "root", "student")
				cursor = db.cursor()  # 使用cursor()方法獲取操作遊標
				sql = "UPDATE student_k SET name = '%s', gender = '%s', age = '%s' \
				 WHERE id = '%s'" % (self.var_name.get(), self.var_gender.get(), self.var_age.get(), self.var_id.get())  # SQL 插入語句
				try:
					cursor.execute(sql)  # 執行sql語句
					db.commit()  # 提交到數據庫執行
					messagebox.showinfo('提示!', '更新成功!')
				except:
					db.rollback()  # 發生錯誤時回滾
					messagebox.showinfo('警告!', '更新失敗,數據庫連接失敗!')
				db.close()  # 關閉數據庫連接

				id_index = self.id.index(self.row_info[0])
				self.name[id_index] = self.var_name.get()
				self.gender[id_index] = self.var_gender.get()
				self.age[id_index] = self.var_age.get()

				self.tree.item(self.tree.selection()[0], values=(
					self.var_id.get(), self.var_name.get(), self.var_gender.get(),
					self.var_age.get()))  # 修改對於行信息
			else:
				messagebox.showinfo('警告!', '不能修改學生學號!')

	def del_row(self):
		res = messagebox.askyesnocancel('警告!', '是否刪除所選數據?')
		if res == True:
			print(self.row_info[0])  # 鼠標選中的學號
			print(self.tree.selection()[0])  # 行號
			print(self.tree.get_children())  # 所有行
			# 打開數據庫連接
			db = pymysql.connect("localhost", "root", "root", "student")
			cursor = db.cursor()  # 使用cursor()方法獲取操作遊標
			sql = "DELETE FROM student_k WHERE id = '%s'" % (self.row_info[0]) # SQL 插入語句
			try:
				cursor.execute(sql)  # 執行sql語句
				db.commit()  # 提交到數據庫執行
				messagebox.showinfo('提示!', '刪除成功!')
			except:
				db.rollback()  # 發生錯誤時回滾
				messagebox.showinfo('警告!', '刪除失敗,數據庫連接失敗!')
			db.close()  # 關閉數據庫連接

			id_index = self.id.index(self.row_info[0])
			print(id_index)
			del self.id[id_index]
			del self.name[id_index]
			del self.gender[id_index]
			del self.age[id_index]
			print(self.id)
			self.tree.delete(self.tree.selection()[0])  # 刪除所選行
			print(self.tree.get_children())


# 學生查看信息界面
class StudentView:
	def __init__(self, parent_window, student_id):
		parent_window.destroy() # 銷燬主界面

		self.window = tk.Tk()  # 初始框的聲明
		self.window.title('關於')
		self.window.geometry('300x450')  # 這裏的乘是小x

		label = tk.Label(self.window, text='學生信息查看', bg='green', font=('Verdana', 20), width=30, height=2)
		label.pack(pady=20)

		self.id = '學號:' + ''
		self.name = '姓名:' + ''
		self.gender = '性別:' + ''
		self.age = '年齡:' + ''
		# 打開數據庫連接
		db = pymysql.connect("localhost", "root", "root", "student")
		cursor = db.cursor()# 使用cursor()方法獲取操作遊標
		sql = "SELECT * FROM student_k WHERE id = '%s'" % (student_id) # SQL 查詢語句
		try:
			# 執行SQL語句
			cursor.execute(sql)
			# 獲取所有記錄列表
			results = cursor.fetchall()
			for row in results:
				self.id = '學號:' + row[0]
				self.name = '姓名:' + row[1]
				self.gender = '性別:' + row[2]
				self.age = '年齡:' + row[3]
		except:
			print("Error: unable to fetch data")
		db.close()		# 關閉數據庫連接

		Label(self.window, text=self.id, font=('Verdana', 18)).pack(pady=5)
		Label(self.window, text=self.name, font=('Verdana', 18)).pack(pady=5)
		Label(self.window, text=self.gender, font=('Verdana', 18)).pack(pady=5)
		Label(self.window, text=self.age, font=('Verdana', 18)).pack(pady=5)

		Button(self.window, text="返回首頁", width=8, font=tkFont.Font(size=16), command=self.back).pack(pady=25)

		self.window.protocol("WM_DELETE_WINDOW", self.back)  # 捕捉右上角關閉點擊
		self.window.mainloop()  # 進入消息循環

	def back(self):
		StartPage(self.window)  # 顯示主窗口 銷燬本窗口


# About頁面
class AboutPage:
	def __init__(self, parent_window):
		parent_window.destroy() # 銷燬主界面

		self.window = tk.Tk()  # 初始框的聲明
		self.window.title('關於')
		self.window.geometry('300x450')  # 這裏的乘是小x

		label = tk.Label(self.window, text='學生信息管理系統', bg='green', font=('Verdana', 20), width=30, height=2)
		label.pack()

		Label(self.window, text='作者:清晨的光明', font=('Verdana', 18)).pack(pady=30)
		Label(self.window, text='blog.csdn.net/kdongyi', font=('Verdana', 18)).pack(pady=5)

		Button(self.window, text="返回首頁", width=8, font=tkFont.Font(size=12), command=self.back).pack(pady=100)

		self.window.protocol("WM_DELETE_WINDOW", self.back)  # 捕捉右上角關閉點擊
		self.window.mainloop()  # 進入消息循環

	def back(self):
		StartPage(self.window)  # 顯示主窗口 銷燬本窗口


if __name__ == '__main__':
	try:
		# 打開數據庫連接 連接測試
		db = pymysql.connect("localhost", "root", "root", "student")
		# 使用cursor()方法獲取操作遊標
		cursor = db.cursor()
		# 如果數據表不存在則創建表 若存在則跳過
		# 設置主鍵唯一
		sql = """CREATE TABLE IF NOT EXISTS student_k(
				id char(20) NOT NULL,
				name char(20) default NULL,
				gender char(5) default NULL,  
				age char(5) default NULL,
				PRIMARY KEY (id)
				
				) ENGINE = InnoDB 
				DEFAULT	CHARSET = utf8
				"""
		cursor.execute(sql)
		# 如果數據表不存在則創建表 若存在則跳過
		sql = """CREATE TABLE IF NOT EXISTS admin_login_k(
						admin_id char(20) NOT NULL,
						admin_pass char(20) default NULL,
						PRIMARY KEY (admin_id)
						) ENGINE = InnoDB 
						DEFAULT	CHARSET = utf8
						"""
		cursor.execute(sql)
		# 如果數據表不存在則創建表 若存在則跳過
		sql = """CREATE TABLE IF NOT EXISTS stu_login_k(
						stu_id char(20) NOT NULL,
						stu_pass char(20) default NULL,
						PRIMARY KEY (stu_id)
						) ENGINE = InnoDB 
						DEFAULT	CHARSET = utf8
						"""
		cursor.execute(sql)

		# 關閉數據庫連接
		db.close()

		# 實例化Application
		window = tk.Tk()
		StartPage(window)
	except:
		messagebox.showinfo('錯誤!', '連接數據庫失敗!')

 下面是我從我電腦數據庫轉儲的SQL文件:

/*
Navicat MySQL Data Transfer

Source Server         : mysql
Source Server Version : 50532
Source Host           : localhost:3306
Source Database       : student

Target Server Type    : MYSQL
Target Server Version : 50532
File Encoding         : 65001

Date: 2019-11-28 15:09:36
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for `admin_login_k`
-- ----------------------------
DROP TABLE IF EXISTS `admin_login_k`;
CREATE TABLE `admin_login_k` (
  `admin_id` char(20) NOT NULL,
  `admin_pass` char(20) DEFAULT NULL,
  PRIMARY KEY (`admin_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of admin_login_k
-- ----------------------------
INSERT INTO `admin_login_k` VALUES ('admin', 'admin');

-- ----------------------------
-- Table structure for `student_k`
-- ----------------------------
DROP TABLE IF EXISTS `student_k`;
CREATE TABLE `student_k` (
  `id` char(20) NOT NULL,
  `name` char(20) DEFAULT NULL,
  `gender` char(5) DEFAULT NULL,
  `age` char(5) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of student_k
-- ----------------------------
INSERT INTO `student_k` VALUES ('182085211003', 'a', '女', '22');
INSERT INTO `student_k` VALUES ('182085211004', 'b', '女', '18');
INSERT INTO `student_k` VALUES ('182085211005', 'abc', '男', '23');
INSERT INTO `student_k` VALUES ('182085211006', 'abc', '女', '24');
INSERT INTO `student_k` VALUES ('182085211008', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211009', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211010', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211011', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('1820852110111', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211012', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211013', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211014', 'Tom2', '男', '23');
INSERT INTO `student_k` VALUES ('182085211015', 'Tom1', '男', '23');
INSERT INTO `student_k` VALUES ('182085211016', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211017', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211018', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211019', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211020', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211021', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('1820852110211', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211022', 'Tom1', '男', '23');
INSERT INTO `student_k` VALUES ('182085211023', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211024', 'Tom', '男', '23');
INSERT INTO `student_k` VALUES ('182085211034', 'Tom', '男', '23');

-- ----------------------------
-- Table structure for `stu_login_k`
-- ----------------------------
DROP TABLE IF EXISTS `stu_login_k`;
CREATE TABLE `stu_login_k` (
  `stu_id` char(20) NOT NULL,
  `stu_pass` char(20) DEFAULT NULL,
  PRIMARY KEY (`stu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of stu_login_k
-- ----------------------------
INSERT INTO `stu_login_k` VALUES ('182085211000', '123456');

-- ----------------------------
-- Table structure for `t_course`
-- ----------------------------
DROP TABLE IF EXISTS `t_course`;
CREATE TABLE `t_course` (
  `SNO` char(255) NOT NULL,
  `COURSE` char(255) DEFAULT NULL,
  `CREDIT` char(255) DEFAULT NULL,
  `GRADE` char(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of t_course
-- ----------------------------
INSERT INTO `t_course` VALUES ('08300205', '程序設計', '4', '88');
INSERT INTO `t_course` VALUES ('08300205', '數據庫', '2.5', '90');
INSERT INTO `t_course` VALUES ('08300205', '力學', '5', '92');
INSERT INTO `t_course` VALUES ('08080929', '數據庫', '2.5', '85');
INSERT INTO `t_course` VALUES ('09350124', '數據庫', '2.5', '92');
INSERT INTO `t_course` VALUES ('09620233', '數據庫', '2.5', '80');
INSERT INTO `t_course` VALUES ('09300218', '數據庫', '2.5', '78');
INSERT INTO `t_course` VALUES ('09010122', '數據庫', '2.5', '87');
INSERT INTO `t_course` VALUES ('08080929', '程序設計', '4', '86');
INSERT INTO `t_course` VALUES ('09010122', '程序設計', '4', '80');
INSERT INTO `t_course` VALUES ('08300516', '程序設計', '4', '76');

-- ----------------------------
-- Table structure for `t_st`
-- ----------------------------
DROP TABLE IF EXISTS `t_st`;
CREATE TABLE `t_st` (
  `SNO` char(11) NOT NULL,
  `SNAME` char(255) DEFAULT NULL,
  `SSEX` char(255) DEFAULT NULL,
  `AGE` char(255) DEFAULT NULL,
  `DEPT` char(255) DEFAULT NULL,
  PRIMARY KEY (`SNO`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of t_st
-- ----------------------------
INSERT INTO `t_st` VALUES ('08080929', '劉超世', '男', '19', '計算機應用技術');
INSERT INTO `t_st` VALUES ('08300205', '李媛媛', '女', '19', '軟件工程');
INSERT INTO `t_st` VALUES ('09300218', '王海超', '男', '19', '軟件工程');
INSERT INTO `t_st` VALUES ('09350124', '王彤', '女', '19', '通信原理');
INSERT INTO `t_st` VALUES ('09620233', '陳曉麗', '女', '21', '通信工程');

覺得有用,點個贊再走吧^_^

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章