0

Based on the following insert of an entry in the database: how would an update of an existing entry would look like? (so: read from database first; look at that data and manipulate in the memory; update the entry in the database).

Remark: the code is simplifying some things, yes; others are missing. The reason why I ask my question is, that I presently did not find a read/update example based on the insert example below.

class Utilities():
    @staticmethod
    def buildDatabaseConnection():
        engine = create_engine('mysql+mysqlconnector://username:password@localhost/dbname')
        sqlAlchemyDeclarations.SqlAlchemyBaseInstantiated.metadata.bind = engine

        DBSession = sessionmaker(bind=engine)
        Utilities.ormSession = DBSession()

    @staticmethod
    def createSomeDummyInstances():
        newEntry = sqlAlchemyDeclarations.Mytable(
        name="the name")
        Utilities.ormSession.add(newProcessingEntry)

        Utilities.ormSession.commit()

Utilities.buildDatabaseConnection()
Utilities.createSomeDummyInstances()
user7468395
  • 1,299
  • 2
  • 10
  • 23
  • 1
    https://stackoverflow.com/questions/9667138/how-to-update-sqlalchemy-row-entry, https://stackoverflow.com/questions/6699360/flask-sqlalchemy-update-a-rows-information, https://stackoverflow.com/questions/10081121/sqlalchemy-select-for-update-example – Ilja Everilä Jan 29 '19 at 17:12
  • thanks, that helped already! – user7468395 Jan 29 '19 at 19:33

0 Answers0