diff --git a/BaseWindow.py b/BaseWindow.py
index 8ad33e7..c0a66c7 100644
--- a/BaseWindow.py
+++ b/BaseWindow.py
@@ -13,5 +13,4 @@ class BaseWindow(Frame):
self.master = master
self.font_style = tkFont.Font(family="Lucida Grande", size=20)
self.button_font = tkFont.Font(family="Lucida Grande", size=10)
- self.conn = pymysql.connect(user="root", password="cyh0110", database="SCT", host="127.0.0.1", port=3306)
-
+ self.conn = pymysql.connect(user="root", password="123123", database="SCT", host="127.0.0.1", port=3306)
diff --git a/README.md b/README.md
index a5f2297..8ee0538 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,16 @@
-# 数据库思维与关系数据库系统仿真
+# 项目编程基本原则
-## 关系数据库系统项目介绍
-### 关系数据库系统项目开发的总体思路
+## 文档及代码编辑的注意事项
-
本章后续内容将以关系数据库的定义与操纵为目标,拟开发一个可交互式练习SQL语句构造与执行的系统,使读者更好地体验关系数据库系统管理大规模数据的基本思维。掌握SQL语言以及基于SQL语言的数据库应用程序的开发和运行。
+### 进度汇报
+**查文档和编程任务是否符合。**
-【目标系统说明】。可交互式练习SQL语句构造与执行的系统:(1)建立一个示例数据库SCT, 内中包含3个数据表(Student, SC和Course),注意本书是以SCT为例,读者做实验时可选择建立其他的数据库和数据表;(2)利用Insert、Delete、Update语句对示例数据库的各个表追加内容;(3)利用Select语句检索示例数据库,并显示检索结果;(4)编制应用程序使用户可以针对固定的表输入检索条件,系统自动构造SQL语句并执行该SQL语句完成检索并输出检索结果。(5)编制应用程序使用户可以对数据库中的任何表进行检索条件输入并构造SQL语句、执行SQL语句显示检索结果。
-【项目开发总体思路】。关系数据库系统项目开发的总体思路如图示意。分为5个层面的开发内容,难度由低到高的被区分为:
-- X1:数据的变化与基本控制【数据结构】
-- X2:屏幕元素及其显示输出【用户界面】
-- X3:问题求解相关算法设计与函数实现【算法】
-- X4:屏幕元素事件识别与控制【人机交互】
-- X5:问题求解相关的算法优化与系统功能拓展【完整系统】
-最终开发的程序可以由用户交互式操作(不用编写程序)来模拟体验数据库系统管理大规模结构化数据的过程。
+首先自查一遍文档,每个编程任务是否符合文档上编程任务的要求---请在进度表中标示【自查:符合 或 不符合】,是按编程任务,不是按X1,X2...
+**查命名问题,函数框架,函数名称,和变量名规范**
+
+(2)按我们前两天讨论的,主函数框架、函数关系调用图、函数名称与变量名称规范化等方面回复【已优化完成,未优化完成】
### 主函数框架示例:
diff --git a/X2/__pycache__/StuSys_X2_bootstrap.cpython-37.pyc b/X2/__pycache__/StuSys_X2_bootstrap.cpython-37.pyc
new file mode 100644
index 0000000..d8cb4a0
Binary files /dev/null and b/X2/__pycache__/StuSys_X2_bootstrap.cpython-37.pyc differ
diff --git a/X2/__pycache__/StuSys_X2_bootstrap.cpython-39.pyc b/X2/__pycache__/StuSys_X2_bootstrap.cpython-39.pyc
new file mode 100644
index 0000000..87556c0
Binary files /dev/null and b/X2/__pycache__/StuSys_X2_bootstrap.cpython-39.pyc differ
diff --git a/X5/StuSys_X5_14.py b/X5/StuSys_X5_14.py
index bfc8f17..806ed9b 100644
--- a/X5/StuSys_X5_14.py
+++ b/X5/StuSys_X5_14.py
@@ -22,8 +22,9 @@ class LoadElement(Frame):
self.master = master
self.table_name = table_name
self.data = []
- self.conn = pymysql.connect(user="root", password="cyh0110", database="SCT", host="127.0.0.1", port=3306)
+ self.conn = pymysql.connect(user="root", password="123123", database="stu_sys", host="127.0.0.1", port=3306)
self.data_frame = pd.read_sql(f"select * from {self.table_name} limit 0", self.conn)
+ #左侧三框框数据
self.font_style = tkFont.Font(family="Lucida Grande", size=20)
self.button_font = tkFont.Font(family="Lucida Grande", size=10)
self.create_widget()
@@ -46,11 +47,11 @@ class LoadElement(Frame):
combo["values"] = tables
combo.bind('<>', self.select_value)
combo.grid(column=0, row=0)
- Button(self, text="装载", width=10, command=self.load).grid(column=1, row=0, padx=5)
+ Button(self, text="装载", width=9, command=self.load).grid(column=1, row=0, padx=5)
def create_tree_widget(self):
# 创建画布,用于展示装载后的数据
- frame = Frame(self, width=50, height=180)
+ frame = Frame(self, width=50, height=250)
frame.grid(row=1, column=0, columnspan=2, sticky=NSEW, pady=5)
frame.grid_columnconfigure(0, weight=1)
frame.grid_rowconfigure(0, weight=1)
@@ -83,12 +84,13 @@ class LoadElement(Frame):
self.create_tree_widget()
+
class FormElement(Frame):
def __init__(self, master, node):
super().__init__(master)
self.node = node
self.data = []
- self.conn = pymysql.connect(user="root", password="cyh0110", database="SCT", host="127.0.0.1", port=3306)
+ self.conn = pymysql.connect(user="root", password="123123", database="stu_sys", host="127.0.0.1", port=3306)
self.font_style = tkFont.Font(family="Lucida Grande", size=20)
self.button_font = tkFont.Font(family="Lucida Grande", size=10)
self.table_names = []
@@ -100,14 +102,6 @@ class FormElement(Frame):
self.select_table(None)
self.create_treeview(pd.read_sql(self.default_query_sql, con=self.conn))
- def get_table_names(self):
- """
- 获取该数据库下所有的表
- :return:
- """
- data_frame = pd.read_sql("show tables", self.conn)
- self.table_names = [i[0] for i in data_frame.values.tolist()]
-
def select_table(self, event):
"""
当下拉框选择表之后,触发该函数,并将tableName改为选择的tableName
@@ -124,13 +118,27 @@ class FormElement(Frame):
self.sql_text.delete(0.0, END)
self.sql_text.insert(1.0, f"SELECT * FROM {self.table_name}")
+ def get_table_names(self):
+ """
+ 获取该数据库下所有的表
+ :return:
+ """
+ data_frame = pd.read_sql("show tables", self.conn)
+ self.table_names = [i[0] for i in data_frame.values.tolist()]
+
def get_field_names(self):
"""
获取所有数据表的所有字段
:return: 返回表内的所有字段
"""
data_frame = pd.read_sql(f"desc {self.table_name}", self.conn)
- return data_frame["Field"].tolist()
+ """
+ field_names = []
+ for field in data_frame["Field"]:
+ field_names.append(f"{self.table_name}.{field}")
+ return field_names
+ """
+ return data_frame["Field"].values.tolist()
def create_form(self):
"""
@@ -139,7 +147,7 @@ class FormElement(Frame):
"""
self.select_table_name = StringVar()
self.select_table_name.set(self.table_name)
- combo = ttk.Combobox(self, width=10, height=1, textvariable=self.select_table_name, font=self.font_style,
+ combo = ttk.Combobox(self, width=8, height=1, textvariable=self.select_table_name, font=self.font_style,
style="TCombobox")
combo["values"] = self.table_names
combo.bind('<>', self.select_table)
@@ -158,7 +166,7 @@ class FormElement(Frame):
checkbutton_var = IntVar()
checkbutton = Checkbutton(self, text='', variable=checkbutton_var)
checkbutton.grid(row=i + 1, column=j * 2, padx=5, pady=5, sticky=E)
- entry = Entry(self, font=self.font_style)
+ entry = Entry(self, font=self.font_style,width=12)
entry.grid(row=i + 1, column=j * 2 + 1, padx=5, pady=5, sticky=W)
self.form_content[field_name] = (entry, checkbutton_var, label, checkbutton)
style = Style()
@@ -166,7 +174,7 @@ class FormElement(Frame):
Button(self, text="构造SQL", command=self.make_sql, width=8, style="custom.TButton"
).grid(column=8, row=0, rowspan=8)
- self.sql_text = Text(self, height=3, font=self.font_style, width=75)
+ self.sql_text = Text(self, height=3, font=self.font_style, width=46)
self.sql_text.grid(row=8, column=0, rowspan=2, columnspan=7, sticky=W)
Button(self, text="\n执行SQL\n", command=self.execute_sql, width=8,
).grid(column=8, row=8, rowspan=2, padx=10)
@@ -195,8 +203,11 @@ class FormElement(Frame):
frame.grid(row=10, column=0, columnspan=10, rowspan=5, sticky=NSEW, pady=10)
frame.grid_columnconfigure(0, weight=1)
frame.grid_rowconfigure(0, weight=1)
- columns = data_frame.keys().tolist()
- tree = ttk.Treeview(frame, columns=columns, show="headings", style="mystyle.Treeview", height=50, selectmode=BROWSE)
+ unique_columns = data_frame.columns[~data_frame.columns.duplicated()]
+ columns = unique_columns.tolist()
+ # 获取查询的列名,将其转换为列表
+ tree = ttk.Treeview(frame, columns=columns, show="headings", style="mystyle.Treeview", height=50,
+ selectmode=BROWSE)
style = ttk.Style()
style.configure("Treeview.Heading", font=self.font_style)
style.configure("Treeview", rowheight=30, font=self.font_style, borderwidth=1)
@@ -229,7 +240,6 @@ class FormElement(Frame):
self.sql_text.delete(0.0, END)
self.sql_text.insert(1.0, sql)
-
class StuSys_X4(BaseWindow):
def __init__(self, master, attr):
super().__init__(master, attr)
@@ -239,6 +249,8 @@ class StuSys_X4(BaseWindow):
def create_left_plate(self):
self.left_frame = Frame(self.master, height=self.attr["height"])
+ self.right_frame = Frame(self.master, height=self.attr["height"])
+ self.right_frame.pack(side=RIGHT, anchor=NW, pady=10, padx=10)
self.left_frame.pack(side=LEFT, anchor=NW, pady=10, padx=10)
load_element1 = LoadElement(self.left_frame, "student")
load_element1.pack(side=TOP, pady=10)
@@ -246,9 +258,9 @@ class StuSys_X4(BaseWindow):
load_element2.pack(side=TOP, pady=10)
load_element2 = LoadElement(self.left_frame, "sc")
load_element2.pack(side=TOP, pady=10)
- message_frame = Frame(self.left_frame, width=50, height=180)
+ message_frame = Frame(self.right_frame, width=50, height=180)
message_frame.pack(side=TOP, pady=10, fill=BOTH)
- self.canvas = Canvas(message_frame, width=50, height=180, bg="#f0f5fa")
+ self.canvas = Canvas(message_frame, width=280, height=1000, bg="#f0f5fa")
self.canvas.configure(background="#f0f5fa")
y_scrollbar = Scrollbar(message_frame, orient="vertical", command=self.canvas.yview)
x_scrollbar = Scrollbar(message_frame, orient="horizontal", command=self.canvas.xview)
@@ -263,7 +275,8 @@ class StuSys_X4(BaseWindow):
for message in self.message:
index = self.message.index(message)
self.canvas.create_text(0, 20 * index, anchor="nw",
- text=message.split("-")[0], font=("", 15), fill="black" if message.split("-")[-1] == "true" else "red")
+ text=message.split("-")[0], font=("", 15),
+ fill="black" if message.split("-")[-1] == "true" else "red")
self.canvas.update()
self.canvas.configure(scrollregion=self.canvas.bbox("all"))
@@ -273,16 +286,15 @@ class StuSys_X4(BaseWindow):
form_element = FormElement(self.right_frame, self)
form_element.pack(side=TOP, pady=10, anchor=NE)
-
if __name__ == '__main__':
"""
minty, lumen, sandstone, yeti, pulse, united, morph, journal, darkly, superhero, solar
cyborg, vapor, simplex, cerculean,
"""
- from pycallgraph2 import PyCallGraph
- from pycallgraph2.output import GraphvizOutput
- from pycallgraph2 import Config
- from pycallgraph2 import GlobbingFilter
+ # from pycallgraph2 import PyCallGraph
+ # from pycallgraph2.output import GraphvizOutput
+ # from pycallgraph2 import Config
+ # from pycallgraph2 import GlobbingFilter
style = "morph"
root = Window(themename=style)
screenwidth = root.winfo_screenwidth()
@@ -290,23 +302,14 @@ if __name__ == '__main__':
root.columnconfigure(0, weight=1)
root.rowconfigure(1, weight=1)
root_attr = {
- "width": screenwidth * 0.83,
- "height": screenheight * 0.85,
+ "width": screenwidth * 0.88,
+ "height": screenheight * 0.90,
}
alignstr = '%dx%d+%d+%d' % (root_attr['width'], root_attr['height'], (screenwidth - root_attr['width']) / 2,
(screenheight - root_attr['height']) / 2)
root.geometry(alignstr)
root.resizable(width=False, height=False)
- output = GraphvizOutput(font_size=30)
- output.output_file = "basic.png"
- output.group_font_size = 40
- config = Config()
- config.trace_filter = GlobbingFilter(include=[
- 'StuSys_X4.*',
- 'FormElement.*',
- 'LoadElement.*',
- ])
- with PyCallGraph(output=output, config=config):
- app = StuSys_X4(root, root_attr)
- ttk.Style().configure("TButton", font="-size 18")
+
+ app = StuSys_X4(root, root_attr)
+ ttk.Style().configure("TButton", font="-size 18")
root.mainloop()
diff --git a/X5/basic.png b/X5/basic.png
new file mode 100644
index 0000000..c0012fe
Binary files /dev/null and b/X5/basic.png differ