I have scoured stackoverflow for answers and none that i found have worked for me.
I want to check if a user already exists in an sqlite3 database
self.c.execute('SELECT username AND password, COUNT(*) FROM users WHERE username=? AND password=? GROUP BY username',(self.reg_username_entry.get(), self.reg_password_entry.get()))
self.c.fetchall()
self.row_count = self.c.rowcount
if self.row_count == 1:
self.my_label = customtkinter.CTkLabel(self.reg_window, text = 'User already exists', font=('Arial', 10)).pack(pady=10)
else:
self.c.execute('INSERT INTO users (username, password) VALUES(?, ?)', (self.reg_username_entry.get(), self.reg_password_entry.get()))
self.conn.commit()
self.Login()
I tried this code. I know it worked for on other database modules, but apparently not on sqlite3 because fetchall() returns a tuple of tuples in sqlite3.
This code does nothing when i type in a user that i know already exists. But it is successful at writing new users to the database if they do not exist.