def set_university_tram_stop(user_id, stop): command = f"INSERT INTO addresses (UserId, University) VALUES({user_id},'{stop}') ON DUPLICATE KEY UPDATE" \ f" University='{stop}'" return DB.exec_command(command)
def get_all(): DB.exec_command('SELECT * FROM addresses', False) return cur.fetchall()
def add_or_update(user_id, address): command = f"INSERT INTO addresses (UserId, Address) VALUES({user_id},'{address}') ON DUPLICATE KEY UPDATE" \ f" Address='{address}'" return DB.exec_command(command)
def set_home_tram_stop(user_id, stop): command = f"INSERT INTO addresses (UserId, Home) VALUES({user_id},'{stop}') ON DUPLICATE KEY UPDATE" \ f" Home='{stop}'" return DB.exec_command(command)
def get_all(): DB.exec_command('SELECT * FROM groups', False) return cur.fetchall()
def contains(user_id): DB.exec_command(f'SELECT * FROM addresses WHERE UserId={user_id}', False) return cur.fetchone()
def get(user_id): DB.exec_command(f'SELECT GroupName FROM groups WHERE UserId={user_id}', False) return cur.fetchone()
def add_or_update(user_id, group): command = f"INSERT INTO groups (UserId, GroupName) VALUES({user_id},'{group}') ON DUPLICATE KEY UPDATE" \ f" GroupName='{group}'" return DB.exec_command(command)
def set_hint_shown(user_id): DB.exec_command( f'UPDATE portal SET HintShown=1 WHERE UserId={user_id}') return cur.fetchone()
def get_all(): DB.exec_command('SELECT * FROM portal', False) return cur.fetchall()
def get_hint_shown(user_id): DB.exec_command(f'SELECT HintShown FROM portal WHERE UserId={user_id}', False) return cur.fetchone()
def update_subjects(user_id, subjects: []): subj_str = ','.join(subjects) command = f"UPDATE portal SET Subjects='{subj_str}' WHERE UserId='{user_id}'" return DB.exec_command(command)
def add_or_update(user_id, login, password): command = f"INSERT INTO portal (UserId, Login, Password) VALUES({user_id}, '{login}', '{password}')" \ f" ON DUPLICATE KEY UPDATE" \ f" Login='******', Password='******'" return DB.exec_command(command)
def get(user_id): DB.exec_command( f'SELECT Login, Password FROM portal WHERE UserId={user_id}', False) return cur.fetchone()
def add_or_update(user_id, expiration_date): command = f"INSERT INTO premium (UserId, ExpirationDate) VALUES({user_id},'{expiration_date}') ON DUPLICATE KEY UPDATE" \ f" ExpirationDate='{expiration_date}'" return DB.exec_command(command)