Skip to content
Advertisement

Tag: sqlmodel

How do I construct a self-referential/recursive SQLModel

I want to define a model that has a self-referential (or recursive) foreign key using SQLModel. (This relationship pattern is also sometimes referred to as an adjacency list.) The pure SQLAlchemy implementation is described here in their documentation. Let’s say I want to implement the basic tree structure as described in the SQLAlchemy example linked above, where I have a

Advertisement