SQLAlchemy terms defined
In January of last year I was working on a project that used SQLAlchemy to manage database interactions. Since many of the terms were new to me back then, I thought it would be handy to define a few of them here.
Provides an intermediary between the object-oriented code and the SQL statements. In practical terms, this allows us to manipulate our objects, and the corresponding SQL command to replicate the actions we've taken will be generated by the ORM, which in this instance is SQLAlchemy.
The object which manages connections to the database. It is used to control and manage the database's resources and DBAPI connections. Usually, there's only one per application.
Represents a series of transactions with the database. Holds all objects which have yet to be written to the database. The session is a staging area where objects can be added and manipulated before pushing the session to the database as a series of SQL statements emitted by the ORM.
Factory object to create sessions. Creates new sessions as needed once instantiated along with the engine. Usually, there's only one per application.
An object in the database, but not part of any session.
Created within the session, but not yet saved to the database.
An object that has been added to the session using the add() method.
An object in the session that is saved in the database.