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()