liveBook · Manning

Hibernate session

As explained in The Quick Python Book, Fourth Edition

Session is a SQLAlchemy unit-of-work object that manages database interactions and transactional changes.

A SQLAlchemy Session is the unit-of-work object used to connect ORM operations to a database and manage transactional changes. Create an engine and table metadata, bind a sessionmaker to the engine, then instantiate a session. section 23.4.1

Use the session to perform database work:

Insert and commit

After defining the people table and creating a session, build an insert object, execute it, and commit the change: session.execute(people_ins); session.commit(). Querying afterward returns the saved row.

How The Quick Python Book, Fourth Edition covers it

How deep it goes
Explains setup, execution, commits, queries, inserts, updates, and deletes, without descending into session internals.
Examples
Uses a people table with Bob, Jill, Joe, and Jane to demonstrate insertion, selection, updating, and deletion.
What it assumes
Assumes familiarity with SQLAlchemy imports, database engines, table schemas, and declarative ORM mappings.
What you can do after
Operate/configure SQLAlchemy sessions to create records, query rows, update objects, delete objects, and commit changes.
How it connects
Connects engines, metadata, tables, transactions, declarative ORM classes, queries, and mapped objects.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Quick Python Book, Fourth Edition. The section links point to the parts of the book it draws on.