-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.py
More file actions
22 lines (17 loc) · 736 Bytes
/
user.py
File metadata and controls
22 lines (17 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sqlite3
class User:
def __init__(self, username, password):
self.username = username
self.password = password
class UserManager:
def __init__(self):
self.connection = sqlite3.connect('lychee.db')
self.cursor = self.connection.cursor()
def register_user(self, username, password):
self.cursor.execute("INSERT INTO users (username, password) VALUES (?, ?)", (username, password))
self.connection.commit()
def authenticate_user(self, username, password):
self.cursor.execute("SELECT * FROM users WHERE username=? AND password=?", (username, password))
return self.cursor.fetchone() is not None
def close(self):
self.connection.close()