Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. from Tkinter import *
  2. import tkSimpleDialog
  3. import MySQLdb
  4. import tkMessageBox
  5.  
  6. # Janela e botão de sair
  7. top = Tk()
  8. top.minsize(width=15, height=10)
  9.  
  10. janela = Frame(top)
  11. janela.pack()
  12.  
  13. botao = Button(janela, text="Sair", command=janela.quit)
  14. botao.pack()
  15.  
  16. # Login e Password
  17. username = tkSimpleDialog.askstring("Login", "Introduza o username: ")
  18. password = tkSimpleDialog.askstring("Login", "Introduza o password: ", show="*")
  19.  
  20. # conexão com o DB
  21. db = MySQLdb.connect(host="localhost", user="root", password="", db="myhotel")
  22. cursor = db.cursor()
  23. cursor.execute("SELECT * FROM login")
  24. result = cursor.fetchall()
  25.  
  26. # Verificar dados
  27. for record in result:
  28.     if username == record[0] and password == record[1]:
  29.         tkMessageBox.showinfo("Login", "Login correto", janela.mainloop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement