Python Forum

Full Version: Check password from sqlite db
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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]