Add login, user_edit, user_info

This commit is contained in:
David Hoppenbrouwers
2022-10-07 14:37:18 +02:00
parent d72fd14c92
commit 6f3b4de047
8 changed files with 151 additions and 8 deletions

View File

@@ -49,5 +49,44 @@ class DB:
return str(parent) + str(children)
return parent
def get_user_password(self, username):
return self._db().execute('''
select user_id, password
from users
where name = ?
''',
(username,)
).fetchone()
def get_user_public_info(self, user_id):
return self._db().execute('''
select name, about
from users
where user_id = ?
''',
(user_id,)
).fetchone()
def get_user_private_info(self, user_id):
return self._db().execute('''
select about
from users
where user_id = ?
''',
(user_id,)
).fetchone()
def set_user_private_info(self, user_id, about):
print('BROH', about)
db = self._db()
db.execute('''
update users
set about = ?
where user_id = ?
''',
(about, user_id)
)
db.commit()
def _db(self):
return sqlite3.connect(self.conn)