24 lines
797 B
Python
24 lines
797 B
Python
from backend.code.modules.database.database import DatabaseModule
|
|
|
|
class AccountRepository():
|
|
def __init__(self, repo: DatabaseModule):
|
|
self.conn = repo.conn
|
|
self.cursor = repo.cursor
|
|
|
|
def SelectByUsername(self, username: str):
|
|
sql = '''
|
|
SELECT *
|
|
FROM user_accounts
|
|
WHERE username = ?
|
|
'''
|
|
self.cursor.execute(sql, [username])
|
|
return self.cursor.fetchone()
|
|
|
|
def InsertAccount(self, user_id: int, username: str, locked: bool = False, active: bool = True):
|
|
sql = '''
|
|
INSERT INTO user_accounts(user_id, username, locked, active)
|
|
VALUES(?, ?, ?, ?)
|
|
'''
|
|
self.cursor.execute(sql, [user_id, username, locked, active])
|
|
self.conn.commit()
|
|
return self.cursor.lastrowid |