Python Forum
Check password from sqlite db - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Check password from sqlite db (/thread-30217.html)



Check password from sqlite db - Maryan - Oct-12-2020

Any help is appreciated, I'm a beginner, and I'm trying to find where is my error. I can set up a new password and insert it into the DB, but I'm not sure how can I fetch that record and match it with the Entry input. I'm getting the except error- fatal error.

the db table is system -> system_password

        self.password_entry = Entry(self.main,
                            width = 30,
                            relief = FLAT,
                            cursor = 'hand2')
        self.password_entry.focus()
        self.password_entry.grid(row = 1, column = 1, pady = 5, padx = 8)
        self.password_entry.config(show = '*', relief = FLAT)

    def chkPass(self):
        pas = self.password_entry.get()
        try:
            con = sqlite3.connection('employer.db')
            cur = con.cursor()

            query = "SELECT system_password FROM 'system'"
            cur.execute(query)
            records = cur.fetchone()
            if pas == records:
                messagebox.showinfo('Sucess', 'Welcome')
            else:
                messagebox.showerror('ERROR', 'Try again')
        except:
            messagebox.showwarning('Warning', 'Fatal Error!', icon = 'warning')


[Image: img-help.png]