예제 #1
0
def import_our_recipes():
    cur.execute("SELECT * FROM recipes")
    bad_recipes = []#54,53,83, 101,108,109,114,115,120,121,122,123,125,126,128,132]
    max_length = 0
    for row in cur.fetchall() :
        if row[0] not in bad_recipes:
            rec = Recipe()
            print row[0]
            rec.recipe_name = row[2]
            rec.recipe_name = clean_string(rec.recipe_name)
            rec.ingredients = row[3].replace("|","\n")
            rec.ingredients = clean_string(rec.ingredients)
            rec.directions = row[4].replace("|","\n")
            rec.directions = clean_string(rec.directions)
            rec.notes =row[5].replace("|","\n")
            rec.notes = clean_string(rec.notes)
            rec.notes = clean_string(rec.notes)
            rec.user_id = 1
            if row[1]:
                rec.timestamp = row[1]
            else:
                rec.timestamp = datetime.strptime('01012013', "%d%m%Y").date()
            rec.image_path = row[9]
            rec.rating = row[8]
            rec.was_cooked = 1
            db_session.add(rec)
            db_session.commit()
예제 #2
0
def import_moms_recipes():
    cur.execute("SELECT * FROM moms")
    bad_recipes = []#5,18,70,77]
    max_length = 0
    for row in cur.fetchall() :
        if row[0] not in bad_recipes:
            rec = Recipe()
            print row[0]
            rec.recipe_name = row[1]
            rec.recipe_name = clean_string(rec.recipe_name)
            
            rec.ingredients = row[3].replace("|","\n")
            rec.ingredients = clean_string(rec.ingredients)
            rec.directions = row[4].replace("|","\n")
            rec.directions = clean_string(rec.directions)
            rec.notes =row[5].replace("|","\n")
            rec.notes = clean_string(rec.notes)
            rec.user_id = 3
            

            db_session.add(rec)
            db_session.commit()