예제 #1
0
    def set_username(self, id, username):
        """Set the username of the user."""
        query = '''UPDATE users
                      SET username = %s
                    WHERE id = %s;'''

        database.commit(query, (username, id))
예제 #2
0
    def set_allergy(self, id, name):
        """Set the name of an allergy."""
        query = '''UPDATE allergies
                      SET name = %s
                    WHERE id = %s'''

        database.commit(query, (name, id))
예제 #3
0
    def set_email(self, id, email):
        """Set the email adress of the user."""
        query = '''UPDATE users
                      SET email = %s
                    WHERE id = %s;'''

        database.commit(query, (mail, id))
예제 #4
0
    def set_ingredient(self, id, name):
        """Set the name of an ingredient."""
        query = '''UPDATE ingredients
                      SET name = %s
                    WHERE id = %s'''

        database.commit(query, (name, id))
예제 #5
0
    def set_roommate(self, id, first_name, middle_name, last_name):
        """Set the name of a roommate."""
        query = '''UPDATE roommates
                      SET first_name = %s,
                          middle_name = %s,
                          last_name = %s
                    WHERE id = %s'''

        database.commit(query, (first_name, middle_name, last_name, id))
예제 #6
0
    def set_password(self, id, password):
        """Set the user password."""
        hash = self.generate_hash(password)

        query = '''UPDATE users
                      SET hash = %s
                    WHERE id = %s;'''

        database.commit(query, (hash, id))
예제 #7
0
    def set_name(self, id, first_name, middle_name, last_name):
        """Set  the name of the user."""
        query = '''UPDATE users
                      SET first_name = %s,
                          middle_name = %s,
                          last_name = %s
                    WHERE id = %s;'''

        database.commit(query, (first_name, middle_name, last_name, id))
예제 #8
0
    def add_user(self, username, email, first_name, middle_name, last_name,
                 password):
        """Add a user to the database."""
        hash = self.generate_hash(password)

        query = '''INSERT INTO users (username, email, first_name, middle_name,
                                      last_name, hash)
                   VALUES (%s, %s, %s, %s, %s, %s)'''

        database.commit(
            query, (username, email, first_name, middle_name, last_name, hash))
예제 #9
0
    def add_roommate(self, user_id, first_name, middle_name, last_name):
        """Add a roommate to the database."""
        handle = self.get_handle(user_id)

        if not handle:
            handle = 1

        query = '''INSERT INTO roommates (handle, user_id, first_name,
                                          middle_name, last_name)
                   VALUES (%s, %s, %s, %s, %s)'''

        database.commit(query, (handle, user_id, first_name, middle_name,
                                last_name))
예제 #10
0
    def delete_roommate(self, id):
        """Delete a roomate from the database."""
        query = '''DELETE FROM roommates
                    WHERE id = %s'''

        database.commit(query, id)
예제 #11
0
    def delete_allergy(self, id):
        """Delete an allergy from the database."""
        query = '''DELETE FROM allergies
                    WHERE id = %s'''

        database.commit(query, id)
예제 #12
0
    def add_allergy(self, name):
        """Add an allergy to the database."""
        query = '''INSERT INTO allergies (name)
                   VALUES (%s)'''

        database.commit(query, name)
예제 #13
0
    def delete_ingredient(self, id):
        """Delete an ingredient from the database."""
        query = '''DELETE FROM ingredients
                    WHERE id = %s'''

        database.commit(query, id)
예제 #14
0
    def add_ingredient(self, name):
        """Add an ingredient to the database."""
        query = '''INSERT INTO ingredients (name)
                   VALUES (%s)'''

        database.commit(query, name)