Esempio n. 1
0
    def create(cls, data):
        mysql = MySQLConnection('recipe_schema')
        query = (
            "insert into recipes (name, description, instructions, cook_time, user_id) values (%(name)s, %(description)s, %(instructions)s, %(cook_time)s, %(user_id)s)"
        )

        recipe = mysql.query_db(query, data)
        return recipe
Esempio n. 2
0
 def is_unique(cls, data):
     is_valid = True
     mysql = MySQLConnection('email_schema')
     query = ("select * from emails where email_address = (%(email)s)")
     test = mysql.query_db(query, data)
     if len(test) > 0:
         is_valid = False
     return is_valid
Esempio n. 3
0
    def edit(cls, data):
        mysql = MySQLConnection('recipe_schema')
        query = (
            "update recipes set name = %(name)s, description = %(description)s, instructions = %(instructions)s, cook_time = %(cook_time)s where id = %(recipe_id)s;"
        )

        recipe = mysql.query_db(query, data)
        return recipe
Esempio n. 4
0
    def add_user(cls, data):
        mysql = MySQLConnection('wall_schema')
        query = (
            "insert into users (email_address, pass_hash, first_name, last_name, spam_ok) values (%(email)s, %(password)s, %(first_name)s, %(last_name)s, %(spam_ok)s)"
        )

        new_email = mysql.query_db(query, data)
        return new_email
Esempio n. 5
0
 def login_validate(data):
     is_valid = True
     mysql = MySQLConnection('wall_schema')
     query = ("select * from users where email_address = %(email_address)s")
     user_check = mysql.query_db(query, data)
     if len(user_check) != 1:
         is_valid = False
         flash('Username or Password is invalid')
     return is_valid
Esempio n. 6
0
    def view_recipe(cls, data):

        mysql = MySQLConnection('recipe_schema').query_db(
            'select * from recipes where recipes.id = %(id)s', data)

        print(mysql)
        recipe = Recipe(mysql[0])
        return recipe
Esempio n. 7
0
 def get_all(cls, data):
     mysql = MySQLConnection('recipe_schema').query_db(
         'select * from recipes where recipes.user_id = %(user_id)s', data)
     recipes = []
     for item in mysql:
         new = Recipe(item)
         recipes.append(new)
     return recipes
Esempio n. 8
0
 def delete(cls, data):
     mysql = MySQLConnection('email_schema')
     query = ("delete from emails where id = %(id)s")
     mysql.query_db(query, data)
     return None
Esempio n. 9
0
    def get_all(cls):
        mysql = MySQLConnection('email_schema')
        query = ('select * from emails')

        all_emails = mysql.query_db(query)
        return all_emails
Esempio n. 10
0
    def add_email(cls, data):
        mysql = MySQLConnection('email_schema')
        query = ("insert into emails (email_address) values (%(email)s)")

        new_email = mysql.query_db(query, data)
        return new_email
Esempio n. 11
0
 def delete(cls, data):
     MySQLConnection('recipe_schema').query_db(
         'delete from recipes where recipes.id = %(id)s', data)
Esempio n. 12
0
 def get_user(cls, data):
     mysql = MySQLConnection('wall_schema')
     query = ("select * from users where email_address = %(email_address)s")
     user = mysql.query_db(query, data)
     return user