Even though SQL Expression Language already provides a good level of abstraction, it still operates with a physical data model, not with business entities.
ORM makes it possible to map business objects to data structures in the database. To show this, let's create a class Car and define the mapping.
When using ORM, we describe the database structure and, at the same time, define the classes that represent business entities. This is done using a system named declarative. In SQLAlchemy, this system is initiated by creating a class that is then used as a base class for other classes:
from sqlalchemy.ext.declarative import declarative_base Base = declarative_base()
The high-level class can now be defined as follows:
class Car(Base): __tablename__ ...