Загрузка данных


import tkinter as tk
from tkinter import messagebox
from db import get_connection

def check_login(login_entry, password_entry, window):
    login = login_entry.get()
    password = password_entry.get()
    conn = get_connection()
    cur = conn.cursor()
    cur.execute("SELECT id, role, full_name FROM users WHERE login = %s AND password = %s", (login, password))
    user = cur.fetchone()
    conn.close()
    if user:
        messagebox.showinfo("Успех", f"Добро пожаловать, {user[2]} ({user[1]})")
    else:
        messagebox.showerror("Ошибка", "Неверный логин или пароль")

window = tk.Tk()
window.title("ООО Обувь — вход")
window.geometry("300x220")
window.configure(bg="white")

tk.Label(window, text="Логин", bg="white", font=("Times New Roman", 11)).pack(pady=(20, 0))
login_entry = tk.Entry(window, font=("Times New Roman", 11))
login_entry.pack()

tk.Label(window, text="Пароль", bg="white", font=("Times New Roman", 11)).pack(pady=(10, 0))
password_entry = tk.Entry(window, show="*", font=("Times New Roman", 11))
password_entry.pack()

tk.Button(window, text="Войти", bg="#00FA9A", font=("Times New Roman", 11), command=lambda: check_login(login_entry, password_entry, window)).pack(pady=20)

window.mainloop()