Open
Description
registry.map_imperatively()
should be used instead.
Reference: https://docs.sqlalchemy.org/en/14/orm/mapping_api.html?highlight=mapper#sqlalchemy.orm.mapper
This involves some refactoring and updates on almost all chapters. Not sure what is the path (update the book first or the branches). I am available to help.
What needs to be done:
- Instead of importing MetaData on orm.py, you import his parent (registry):
from sqlalchemy.orm import registry
mapper_registry = registry()
- On each Table, you pass as second argument
mapper_registry.metadata
instead ofmetadata
. Eg.:
order_lines = Table(
"order_lines",
mapper_registry.metadata,
Column("id", Integer, primary_key=True, autoincrement=True),
Column("sku", String(255)),
Column("qty", Integer, nullable=False),
Column("orderid", String(255)),
)
- You add the classes and tables with
mapper_registry.map_imperatively
instead ofmapper
. Eg.:
def start_mappers():
mapper_registry.map_imperatively(model.OrderLine, order_lines)
...
Metadata
Metadata
Assignees
Labels
No labels