SQLAlchemy Object Lifecycle

SQLAlchemy Object Lifecycle Recall We can insert new records into the database using SQLAlchemy by running. - person = Person(name='Amr') - db.session.add(person) - db.session.commit() which will build a transaction for inserting in a person instance in our model/table, and persist it to the database upon calling commit(). db.session: It isn't until we execute db.session() that we commit anything to the database. Every time we want to interact with the database we start a connection and end a connection when all of the interactions are done. Within that interaction session, We wound up creating transactions that we commit to the database every time that we want to commit work to the database. So an important thing to keep in mind: - Proposed database changes are not immediately committed to the database once they're defined. - Changes go through stages in order to provide the ability to "undo" a mistake. - before committing it to a database. There are 4 st...