python连接mysql,做基础的登陆和注册页面以及对应验证

  • Post author:
  • Post category:mysql




环境

python 3.8.3

mysql 5.5



功能

与数据库连接,实现登陆和注册,包括登陆账号密码验证,以及注册检测重复。并且能对数据库做出修改



代码

import pymysql
from tkinter import *

def register():
    global register_screen
    register_screen = Toplevel(main_screen)
    register_screen.title("注册")
    register_screen.geometry("300x250")
    global username
    global password
    global username_entry
    global password_entry
    username = StringVar()
    password = StringVar()
    Label(register_screen, text="请输入", bg="white").pack()
    Label(register_screen, text="").pack()
    username_lable = Label(register_screen, text="用户名 * ")
    username_lable.pack()
    username_entry = Entry(register_screen, textvariable=username)
    username_entry.pack()
    password_lable = Label(register_screen, text="密码 * ")
    password_lable.pack()
    password_entry = Entry(register_screen, textvariable=password, show='*')
    password_entry.pack()
    Label(register_screen, text="").pack()
    Button(register_screen, text="注册", width=10, height=1, bg="white", command=register_user).pack()

def login():
    global login_screen
    login_screen = Toplevel(main_screen)
    login_screen.title("登录")
    login_screen.geometry("300x250")
    Label(login_screen, text="请输入"



版权声明:本文为weixin_45067603原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。