Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo 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
Ejemplo 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
Ejemplo n.º 6
0
 def delete(cls, data):
     mysql = MySQLConnection('email_schema')
     query = ("delete from emails where id = %(id)s")
     mysql.query_db(query, data)
     return None
Ejemplo n.º 7
0
    def get_all(cls):
        mysql = MySQLConnection('email_schema')
        query = ('select * from emails')

        all_emails = mysql.query_db(query)
        return all_emails
Ejemplo n.º 8
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
Ejemplo n.º 9
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