数据库课程设计 python+mysql+图形化界面

这篇具有很好参考价值的文章主要介绍了数据库课程设计 python+mysql+图形化界面。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

进行操作的表

数据库课程设计 python+mysql+图形化界面

 文章来源地址https://www.toymoban.com/news/detail-485756.html

增加界面

import tkinter as tk
import pymysql

def frame():
    global root
    root = tk.Tk()
    root.title('录入窗口')
    v1 = tk.StringVar()
    v2 = tk.StringVar()
    v3 = tk.StringVar()

    # 姓名标签,位置在第0行第0列
    tk.Label(root, text='姓名:').grid(row=0, column=0)
    # 电话标签,位置在第1行第0列
    tk.Label(root, text='电话:').grid(row=1, column=0)
    # 学号标签,位置在第3行第0列
    tk.Label(root, text='学号:').grid(row=2, column=0)
    # 姓名输入框
    global input1
    input1 = tk.Entry(root, textvariable=v1)
    input1.grid(row=0, column=1, padx=10, pady=5)
    # 电话输入框
    global input2
    input2 = tk.Entry(root, textvariable=v2)
    input2.grid(row=1, column=1, padx=10, pady=5)
    #学号输入框
    global input3
    input3 = tk.Entry(root, textvariable=v3)
    input3.grid(row=2, column=1, padx=10, pady=5)
    # 登录按钮
    tk.Button(root, text='录入', width=10, command=auto_insert1).grid(row=3, column=0, sticky=tk.W, padx=10, pady=5)
    # 退出按钮
    tk.Button(root, text='取消', width=10, command=exit_login).grid(row=3, column=1, sticky=tk.E, padx=10, pady=5)
    root.mainloop()


def auto_insert1():
    db = pymysql.connect(host="localhost", user="root", password="123456", db="test", port=3306)
    tcursor = db.cursor()
    entry1 = input1.get()
    entry2 = input2.get()
    entry3 = input3.get()
    sql = 'insert into client_copy values(%s,%s,%s)'
    param =(entry1,entry2,entry3)
    tcursor.execute(sql,param)
    print("数据插入成功\n")
    db.commit()


def exit_login():
    root.destroy()
    pass

if __name__ == '__main__':
    frame()

数据库课程设计 python+mysql+图形化界面

 

删除界面

import tkinter as tk
import pymysql

def frame():
    global root
    root = tk.Tk()
    root.title('删除窗口')
    v1 = tk.StringVar()


    # 姓名标签,位置在第0行第0列
    tk.Label(root, text='姓名:').grid(row=0, column=0)
    # 姓名输入框
    global input1
    input1 = tk.Entry(root, textvariable=v1)
    input1.grid(row=0, column=1, padx=10, pady=5)
    # 登录按钮
    tk.Button(root, text='删除', width=10, command=auto_delete).grid(row=3, column=0, sticky=tk.W, padx=10, pady=5)
    # 退出按钮
    tk.Button(root, text='取消', width=10, command=exit_login).grid(row=3, column=1, sticky=tk.E, padx=10, pady=5)
    root.mainloop()


def auto_delete():
    db = pymysql.connect(host="localhost", user="root", password="123456", db="test", port=3306)
    tcursor = db.cursor()
    entry1 = input1.get()
    sql = 'delete from client_copy where client_Name=%s'
    param =(entry1)
    tcursor.execute(sql,param)
    print("数据删除成功\n")
    db.commit()


def exit_login():
    root.destroy()
    pass

if __name__ == '__main__':
    frame()

 数据库课程设计 python+mysql+图形化界面

修改界面

import tkinter as tk
import pymysql

def frame():
    global root
    root = tk.Tk()
    root.title('修改窗口')
    v1 = tk.StringVar()
    v2 = tk.StringVar()

    # 姓名标签,位置在第0行第0列
    tk.Label(root, text='新号码:').grid(row=0, column=0)
    # 电话标签,位置在第1行第0列
    tk.Label(root, text='学号为:').grid(row=1, column=0)

    # 姓名输入框
    global input1
    input1 = tk.Entry(root, textvariable=v1)
    input1.grid(row=0, column=1, padx=10, pady=5)
    # 电话输入框
    global input2
    input2 = tk.Entry(root, textvariable=v2)
    input2.grid(row=1, column=1, padx=10, pady=5)

    # 登录按钮
    tk.Button(root, text='修改', width=10, command=auto_update).grid(row=3, column=0, sticky=tk.W, padx=10, pady=5)
    # 退出按钮
    tk.Button(root, text='取消', width=10, command=exit_login).grid(row=3, column=1, sticky=tk.E, padx=10, pady=5)
    root.mainloop()


def auto_update():
    db = pymysql.connect(host="localhost", user="root", password="123456", db="test", port=3306)
    tcursor = db.cursor()
    entry1 = input1.get()
    entry2 = input2.get()
    sql = 'update client_copy set telephone=%s where studentNo=%s'
    param = (entry1, entry2)
    tcursor.execute(sql, param)
    print("数据修改成功\n")
    db.commit()

def exit_login():
    root.destroy()
    pass

if __name__ == '__main__':
    frame()

 数据库课程设计 python+mysql+图形化界面

 查找界面

import tkinter as tk
import pymysql
# 导入消息对话框子模块
import tkinter.messagebox
global root,name,telephone,studentNo
global label
#import urllib
#创建主窗口


#查询按钮响应函数
def select(label,name,telephone,studentNo):
    sname = label.get()
    print('input: ',sname)
#查询刚才插入的数据
#由于刚才已经关闭了数据库连接,需要重新创建Connection对象和Cursor对象
    db= pymysql.connect(host="localhost", user="root", password="123456", db="test", port=3306)
    tcursor = db.cursor()
    #c = conn.execute('''select * from footballers''')
    #c = conn.execute("select * from footballers where name like?",(sname,))
    print("select * from client_copy where client_Name like '%s"+sname+"%s'")
    sql = 'select * from client_copy where client_Name like  %s'
    tcursor.execute(sql,sname)
    #print(c) #<sqlite3.Cursor object at 0x00000000007E25E0>
    list_re = tcursor.fetchall()
    print('result: ', list_re) #[('艾克森', '15', 'ChOxM1xC0BiAe2D7AAAN-qiRteQ443.png')]
    if len(list_re) <= 0:
        tkinter.messagebox.showinfo('提示',sname+'客户不存在,请输入其他客户姓名!')
    else:
        print('result_name: ', list_re[0][0])
    name.set(list_re[0][0])  # 姓 名
    telephone.set(list_re[0][1])  # 俱乐部
    studentNo.set(list_re[0][2])  # 国籍
    #数据成功提取出来了
    #name text, club text, nation text, height text, position text, age text, weight text, num text, birthday text, habit text
    db.close()
#定义一个返回按钮调用的返回函数:callback
def exit_program():
    quit()


def main():
    root = tk.Tk()
    root.title('客户姓名')
    # 设置窗口大小
    root.minsize(500, 200)
    # 定义变量
    name = tk.StringVar()
    name.set('')
    telephone = tk.StringVar()
    telephone.set('')
    studentNo = tk.StringVar()
    studentNo.set('')
    # name text, club text, nation text, height text, position text, age text, weight text, num text, birthday text, habit text
    input_name = tk.Label(root, text = '请输入客户姓名:').place(x = 30, y = 30)
    label = tk.StringVar()
    entry = tk.Entry(root,bg='#ffffff',width=20,textvariable=label).place(x=130,y=30,anchor='nw')
#按钮

    select_button = tk.Button(root,bg='white',text='查询',width=10,height=1,command=lambda :select(label,name,telephone,studentNo)).place(x=280,y=26,anchor='nw')
    exit_button = tk.Button(root,bg='white',text='退出',width=10,height=1,command=lambda :exit_program()).place(x=380,y=26,anchor='nw')
    #command是Button中的option项,可以指定点击button时调用的callback函数
    #name text, club text, nation text, height text, position text, age text, weight text, num text, birthday text, habit text
    le_client_Name = tk.Label(root, text = '姓 名:').place(x = 40, y = 80)
    le_student = tk.Label(root, text = '电 话:').place(x = 40, y = 110)
    le_studentNo = tk.Label(root, text = '学 号:').place(x = 40, y = 140)


    le_client_Name = tk.Label(root, textvariable=name).place(x=100, y=80)  # 姓 名
    le_telephone = tk.Label(root, textvariable=telephone).place(x=100, y=110)  # 电话
    le_studentNo = tk.Label(root, textvariable=studentNo).place(x=100, y=140)  # 学号
    #显示图片
    #pilImage = Image.open("imgs/1574777943.3190248.png")
    #tkImage = ImageTk.PhotoImage(image=pilImage)
    #label_nation = Label(root, image=tkImage).place(x=90, y=130, anchor='nw')
    root.mainloop()


if __name__ == '__main__':
    main()

数据库课程设计 python+mysql+图形化界面

 

到了这里,关于数据库课程设计 python+mysql+图形化界面的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • MongoDB 数据库数据导入 - 关于如何使用 csv 导入数据的命令方法、图形界面可视化导入方法

    兴趣使然,突发奇想,想到了就写,就当打发时间了。 csv文件路径问题,绝对路径和相对路径都可以 type 没有=号,也是可以的,空格自动识别 将 测试表.csv 文件导入到 mongodatabase 库, mycollection 集合中,导入时必须指定列名称 (如果 csv 文件第一行是列名称,也会被当成数据

    2023年04月22日
    浏览(45)
  • 人脸识别系统OpenCV+dlib+python(含数据库)Pyqt5界面设计 项目源码 毕业设计

    Python语言、dlib、OpenCV、Pyqt5界面设计、sqlite3数据库      本系统使用dlib作为人脸识别工具,dlib提供一个方法可将人脸图片数据映射到128维度的空间向量,如果两张图片来源于同一个人,那么两个图片所映射的空间向量距离就很近,否则就会很远。因此,可以通过提取图片并

    2024年02月05日
    浏览(49)
  • 数据库原理课程设计 — 学业课程预警系统

    一、选题背景 21世纪的社会可谓日新月异,科学技术突飞猛进,经济知识和信息产业初见端倪,特别是信息技术和网络技术的讯速发展和广泛应用,对社会的政治、经济、军事、文化等领域产生越来越深刻的影响。学校也不例外地快速发展着,而且要求也在不断变化。学生的

    2024年02月13日
    浏览(36)
  • 数据库概论课程设计-汽车租赁公司数据库系统的设计

    进入新的世纪以来,经济的快速发展,让很多东西都快速的淘汰了,好多新型的东西也逐渐进入我的视野,而更有好多以前很贵的东西,渐渐降价普及了,汽车逐渐走进了千家万户。而汽车作为一种高价位消费品,结合我国低购买力的国情,很多人就买不起汽车了,所以公司

    2024年02月02日
    浏览(58)
  • 数据库系统课程设计(高校成绩管理数据库系统的设计与实现)

    目录 1、需求分析 1 1.1 数据需求描述 1 1.2 系统功能需求 3 1.3 其他性能需求 4 2、概念结构设计 4 2.1 局部E-R图 4 2.2 全局E-R图 5 2.3 优化E-R图 6 3、逻辑结构设计 6 3.1 关系模式设计 6 3.2 数据类型定义 6 3.3 关系模式的优化 8 4、物理结构设计 9 4.1 聚簇设计 9 4.2 索引设计 9 4.3 分区设

    2024年02月03日
    浏览(53)
  • 医院管理数据库课程设计

    一节复一节,千枝攒万叶。我自不开花,免撩蜂与蝶。 皓首犹贪学,谦虚德益丰。潜神无朕际,悟物不言中。 我将其开源.但希望你能从中学习到数据库设计思想. 诚然,我不是一名DBA,我仅仅读过半本高性能MySQL(第3版)和一本数据库系统概论(第5版),一本java开发手册(华山版).我

    2024年02月05日
    浏览(30)
  • 数据库课程设计------书店管理系统

    书店会员管理系统 具体的效果图看博客-----书店管理系统2(https://blog.csdn.net/qq_45981397/article/details/124062654?spm=1001.2014.3001.5502) 需求分析 (1).信息需求 书店的管理人员和员工可以为管理系统添加图书的购买记录和退书记录. 会员可以购买图书以及退书,工作人员对会员的姓名,

    2024年02月04日
    浏览(34)
  • 数据库课程设计-人事管理系统

    学期就要结束了,要完成一个数据库的课程设计项目,想想自己一个学期下来啥也没学到,现在突然要独立完成一个小项目,不能偷懒,记录一下吧。 代码已经放在文章末尾 ^ v ^ 完成软件下载与环境配置,成功运行老师写好的学生管理系统。  第一次实现用代码弹出具体的

    2024年02月05日
    浏览(40)
  • 数据库课程设计(教室设备故障报修系统)

      内容与要求: 完成需求分析,写出功能需求和数据需求描述; 在需求分析的基础上,完成数据库概念结构设计、逻辑结构设计、物理结构设计和数据库创建; 完成视图、存储过程设计,要求定义合理。 在应用程序中合理运用存储过程,正确运用DML语句。 1.1 设计的背景和

    2024年02月12日
    浏览(35)
  • java课程设计(学生信息管理系统设计)+数据库

    🔍 🔎 本期带领大家一起来学习 java课程设计(学生信息管理系统设计)+数据库 的实现思路 🔍 🔎 学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计学生信息管理系统,使之能提供以下功能: 1、系统以菜单方式工作 2、学生信息录入功能

    2024年02月08日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包