def add_participant(self,userid): with ConnectionPool() as cursor: cursor.execute('INSERT into event_user values(%s,%s)' , (self.event_id, userid)) cursor.execute('SELECT username FROM user_table WHERE userid = %s' , (userid,)) participant = cursor.fetchone() self.participant_arr.append(participant[0])
def delete_participant(self, userid): with ConnectionPool() as cursor: cursor.execute('DELETE FROM event_user WHERE user_id = %s' ,(userid,)) cursor.execute('SELECT username FROM user_table WHERE userid = %s' , (userid,)) participant = cursor.fetchone() self.participant_arr.remove(participant[0])
def is_seen(self): with ConnectionPool() as cursor: cursor.execute( 'UPDATE news_table SET seen = %s WHERE news_id = %s', (True, self.news_id))
def delete_new(self): with ConnectionPool() as cursor: cursor.execute('DELETE FROM news_table WHERE news_id = %s', (self.news_id, ))
def update_email(self, mail): with ConnectionPool() as cursor: cursor.execute( 'UPDATE user_table set email = %s WHERE userid = %s', (mail, self.id)) self.email = mail
def get_owner_name(self): with ConnectionPool() as cursor: cursor.execute('SELECT username FROM user_table WHERE userid = %s' , (self.owner,)) self.owner_name = cursor.fetchone()[0]
def update_username(self, usern): with ConnectionPool() as cursor: cursor.execute( 'UPDATE user_table set username = %s WHERE userid = %s', (usern, self.id)) self.username = usern
def delete_account(self): with ConnectionPool() as cursor: cursor.execute('DELETE FROM user_table WHERE userid = %s', (self.id, ))
def save_to_db(self): with ConnectionPool() as cursor: cursor.execute( 'INSERT INTO user_table(first_name, surname, username, email, passwrd) VALUES(%s,%s,%s,%s,%s);', (self.first_name, self.surname, self.username, self.email, self.password))
def remove_request(self, reqid): with ConnectionPool() as cursor: cursor.execute('DELETE FROM request_table where request_id = %s', (reqid, ))
def delete_comment(self): with ConnectionPool() as cursor: cursor.execute('DELETE FROM comment_table WHERE comment_id = %s', (self.comment_id, ))