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
- SQLAlchemy Core vs ORM
- Defining Models
- Querying with the Session
- Relationships and Joins