Advertisement
bluke90

Untitled

May 7th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.23 KB | None | 0 0
  1. from tkinter import *
  2. import time
  3. from pymysql import cursors
  4. import pymysql
  5. #####
  6. lWindow = Tk()
  7. lWindow.geometry("210x175")
  8. ###############
  9.  
  10. def lClick():
  11.     __uID = uID.get()
  12.     __uName = uName.get()
  13.     __passW = passW.get()
  14.     print(__uName)
  15.     print(__passW)
  16.     auth = Label(lWindow, text="Authorizing...",font=("Areial Bold", 10))
  17.     auth.place(x=-10,y=99)
  18.     time.sleep(0.5)
  19.     time.sleep(1)
  20.     def authorize():
  21.         if __uID == "01":
  22.             auth.configure(text='''
  23.            User Authenticated...
  24.            Accessing Database
  25.            ''')
  26.             ##############################################################
  27.             def dbCon():
  28.                 con = pymysql.connect(host='192.***.***.**',
  29.                     user='****',
  30.                     password='*****',
  31.                     db='python1',
  32.                     charset='utf8mb4',
  33.                     cursorclass=pymysql.cursors.DictCursor)
  34.                 with con:
  35.                     cur = con.cursor()
  36.                     cur.execute("SELECT * FROM users WHERE 'id' = '{0}'".format(__uID))
  37.                     rows = cur.fetchall()
  38.                     for row in rows:
  39.                         db_username = row['username']
  40.                         db_password = row['password']
  41.                 def logon():
  42.                     if __uName == db_username:
  43.                         auth.configure(text="DataBase Connected")
  44.                     else:
  45.                         auth.configure(text="Error Has Occured")
  46.                 logon()
  47.             dbCon()
  48.         else:
  49.             auth.configure(text="Not Authorized")
  50.     authorize()
  51.             ##############################################################
  52.            
  53.  
  54.    
  55.    
  56. ###############
  57. uIDLbl = Label(lWindow, text="User ID:")
  58. uIDLbl.place(x=5,y=5)
  59. uID = Entry(lWindow)
  60. uID.place(x=70,y=5)
  61. uNameLbl = Label(lWindow, text="Username:")
  62. uNameLbl.place(x=5,y=27)
  63. uName = Entry(lWindow)
  64. uName.place(x=70,y=27)
  65. passWLbl = Label(lWindow, text="Password:")
  66. passWLbl.place(x=5,y=50)
  67. passW = Entry(lWindow, show="*")
  68. passW.place(x=70,y=50)
  69. lBtn = Button(lWindow, text="Login", command=lClick)
  70. lBtn.place(x=50,y=72, width=100)
  71. #################
  72. lWindow.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement