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 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 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 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 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())
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(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())
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())
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())
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 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(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(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 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 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())
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 insert(image): conn = ConnectionDB().getConnection() cursor = conn.cursor() try: cursor.execute('INSERT INTO images (name, id_recipe) VALUES (?,?)', (image.name, image.id_recipe)) conn.commit() return cursor.lastrowid except sqlite3.Error as error: print(error.with_traceback())
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())
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())
def insert(instruction): conn = ConnectionDB().getConnection() cursor = conn.cursor() try: cursor.execute( 'INSERT INTO instructions (text_ins, id_section) VALUES (?, ?)', (instruction.text_ins, instruction.id_section)) conn.commit() return cursor.lastrowid except sqlite3.Error as error: print(error.with_traceback())
def insert(recipe): conn = ConnectionDB().getConnection() cursor = conn.cursor() try: if recipe.id_src is None: cursor.execute('INSERT INTO recipes (name, nbr_person) VALUES (?,?)', (recipe.name, recipe.nbr_person,)) else: cursor.execute('INSERT INTO recipes (name, nbr_person, id_src) VALUES (?,?,?)', (recipe.name, recipe.nbr_person, recipe.id_src)) conn.commit() return cursor.lastrowid except sqlite3.Error as error: print(error.with_traceback())
def removeIngredientFromDB(id_sec, id_ing): conn = ConnectionDB().getConnection() cursor = conn.cursor() try: cursor.execute( 'DELETE FROM map_section_ingredient WHERE id_section = ? AND id_ingredient = ?', ( id_sec, id_ing, )) conn.commit() except sqlite3.Error as error: print(error.with_traceback())