I am developing a small cooking recipe application. I have a problem when it comes to updating data taken from a table (QTbableWidget). The updated data may contain more rows than the original already in the database ( or less).
I usually use a dictionary with the keys corresponding to the table column fields to transfer the data to the database. My first impression is to delete all the rows in the database as it pertains to the data and insert the new data but this does not seem very elegant. Is there a way to insert, delete and update all at one series (grouping) of commands? The database: """ define the database: tblCategory, tblIngredients, tblRecipe """ class Recipe(Base): __tablename__ = 'tblRecipe' recipeKey = Column(Integer, primary_key=True) recipeName = Column(String(100)) recipeCategory = Column(Integer, ForeignKey("tblCategory.categoryKey")) recipeDescription = Column(String(500)) ingredient = relationship("Ingredients", cascade="save-update, merge, delete, delete-orphan") class Catagory(Base): __tablename__ = 'tblCategory' categoryKey = Column(Integer, primary_key=True) categoryName = Column(String(100)) class Ingredients(Base): __tablename__ = 'tblIngredients' ingredientKey = Column(Integer, primary_key=True) ingredientRecipeKey = Column(Integer, ForeignKey("tblRecipe.recipeKey")) ingredientDescription = Column(String(100)) ingredientQuantity = Column(String(100)) recipe = relationship("Recipe", back_populates="tblIngredients") The target table is: Ingredients The dialog uses a Table to display the data. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/0570a6cb-a63e-41c8-ab64-78ec0db13ed2o%40googlegroups.com.