Beispiel #1
0
def deleteByName(name):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('DELETE FROM ingredients WHERE name = ?', (name, ))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #2
0
def deleteById(id_sec):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('DELETE FROM sections WHERE id = ?', (id_sec, ))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def update(source):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('UPDATE sources SET name = ? WHERE id = ?', (source.name, source.id_src))
        conn.commit()
    except sqlite3.Error as error:
        print("FAIL")
def deleteByRecipe(id_recipe):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('DELETE FROM images WHERE id_recipe = ?', (id_recipe, ))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def eraseCategoryMapping(id_recipe):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('DELETE FROM map_recipe_category WHERE id_recipe = ?', (id_recipe,))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def deleteById(id_src):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('DELETE FROM sources WHERE id = ?', (id_src,))
        conn.commit()
    except sqlite3.Error as error:
        print("FAIL")
def update(image):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('UPDATE images SET name = ? AND id_recipe WHERE id = ?',
                       (image.name, image.id_recipe, image.id_img))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #8
0
def update(ingredient):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('UPDATE ingredients SET name = ? WHERE id = ?',
                       (ingredient.name, ingredient.id_ing))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def addTool(recipe, tool):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('INSERT INTO map_recipe_tool (id_recipe, id_tool) VALUES (?,?)',
                       (recipe.id_recipe, tool.id_tool,))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #10
0
def update(category):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('UPDATE categories SET name = ? WHERE id = ?',
                       (category.name, category.id_cat))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def update(tool):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('UPDATE tools SET name = ? WHERE id = ?',
                       (tool.name, tool.id_tool,))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def update(recipe):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('UPDATE recipes SET name = ?, nbr_person = ?, id_src = ? WHERE id = ?',
                       (recipe.name, recipe.nbr_person, recipe.id_src, recipe.id_recipe))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def insert(tool):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('INSERT INTO tools (name) VALUES (?)', (tool.name,))
        conn.commit()
        return cursor.lastrowid
    except sqlite3.Error as error:
        print(error.with_traceback())
def update(instruction):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('UPDATE instructions SET text_ins = ? WHERE id = ?',
                       (instruction.text_ins, instruction.id_ins))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def deleteById(id_tool):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('DELETE FROM tools WHERE id = ?', (id_tool,))
        cursor.execute('DELETE FROM map_recipe_tool WHERE id_tool = ?', (id_tool,))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def addCategory(id_recipe, id_cat):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('''INSERT INTO map_recipe_category (id_recipe, id_category) 
            VALUES (?,?)''', (id_recipe, id_cat))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #17
0
def findOneById(id_sec):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('SELECT * FROM sections WHERE id = ?', (id_sec, ))
        row = cursor.fetchone()
        section = Section(id_sec, row[1], row[2])
        return section
    except sqlite3.Error as error:
        print(error.with_traceback())
def findAll():
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        tools = []
        for row in cursor.execute("SELECT * FROM tools"):
            tools.append(Tool(row[0], row[1]))
        return tools
    except sqlite3.Error as error:
        print(error.with_traceback())
def findOneByName(name):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('SELECT * FROM tools WHERE name = ?', (name,))
        row = cursor.fetchone()
        tool = Tool(row[0], name)
        return tool
    except sqlite3.Error as error:
        print(error.with_traceback())
def findOneById(id_tool):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('SELECT * FROM tools WHERE id = ?', (id_tool,))
        row = cursor.fetchone()
        tool = Tool(id_tool, row[1])
        return tool
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #21
0
def eraseAllMappingBySection(id_section):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute(
            'DELETE FROM map_section_ingredient WHERE id_section = ?',
            (id_section, ))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #22
0
def addIngredientToDB(id_sec, id_ing, quantity, unit):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute(
            '''INSERT INTO map_section_ingredient (id_section, id_ingredient, quantity, unit) 
            VALUES (?,?,?,?)''', (id_sec, id_ing, quantity, unit))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
def findOneByName(name):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('SELECT * FROM sources WHERE name = ?', (name,))
        row = cursor.fetchone()
        source = Source(row[0], name)
        return source
    except sqlite3.Error as error:
        print("FAIL")
Beispiel #24
0
def findAll():
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        categories = []
        for row in cursor.execute("SELECT * FROM categories"):
            categories.append(Category(row[0], row[1]))
        return categories
    except sqlite3.Error as error:
        print(error.with_traceback())
def findAll():
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        instructions = []
        for row in cursor.execute("SELECT * FROM instructions"):
            instructions.append(Instruction(row[0], row[1], row[2]))
        return instructions
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #26
0
def insert(ingredient):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('INSERT INTO ingredients (\'name\') VALUES (?)',
                       (ingredient.name, ))
        conn.commit()
        return cursor.lastrowid
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #27
0
def findOneById(id_ing):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('SELECT * FROM ingredients WHERE id = ?', (id_ing, ))
        row = cursor.fetchone()
        ingredient = Ingredient(id_ing, row[1])
        return ingredient
    except sqlite3.Error as error:
        print(error.with_traceback())
def findAll():
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        sources = []
        for row in cursor.execute("SELECT * FROM sources"):
            sources.append(Source(row[0], row[1]))
        return sources
    except sqlite3.Error as error:
        print("FAIL")
Beispiel #29
0
def update(section):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute(
            'UPDATE sections SET name = ? AND id_recipe = ? WHERE id = ?',
            (section.name, section.id_recipe, section.id_sec))
        conn.commit()
    except sqlite3.Error as error:
        print(error.with_traceback())
Beispiel #30
0
def findOneById(id_cat):
    conn = ConnectionDB().getConnection()
    cursor = conn.cursor()

    try:
        cursor.execute('SELECT * FROM categories WHERE id = ?', (id_cat, ))
        row = cursor.fetchone()
        category = Category(id_cat, row[1])
        return category
    except sqlite3.Error as error:
        print(error.with_traceback())