Search⌘ K
AI Features

Create SQLAlchemy Classes

Understand how to create SQLAlchemy classes that define PostgreSQL tables as Python objects. This lesson helps you separate storage logic from business logic, manage database schema with migrations, and prepare the database for integration testing.

For part of our test suite, we’ll need to create and populate the test database with our initial data. However, we also need to define somewhere the tables that will be contained in the database. This is where SQLAlchemy’s ORMORM comes into play since we define the tables in terms of Python objects.

Updated requriments

We’ve already installed the SQLAlchemy ...