0Pricing
Python Academy · Lesson

SQLAlchemy Core vs ORM

Understand the two layers.

What is SQLAlchemy?

SQLAlchemy is the most popular Python toolkit for working with relational databases. It offers two layers: Core and the ORM.

You install it with pip install sqlalchemy.

from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory:')
print('Engine:', engine)

The Engine

Both layers start with an Engine, created by create_engine(). It manages the connection pool and knows how to talk to your specific database via a URL.

from sqlalchemy import create_engine
engine = create_engine('sqlite:///app.db')
print('Dialect:', engine.dialect.name)

All lessons in this course

  1. SQLAlchemy Core vs ORM
  2. Defining Models
  3. Querying with the Session
  4. Relationships and Joins
← Back to Python Academy