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 struct…
Tag: self-referencing-table
Self-referencing many-to-many relationship with an association object in SQLAlchemy
I’ve found examples for a self-referencing many-to-many relationship with an association table. How can I achieve the same using an association object? The code below is based on: How can I achieve a self-referencing many-to-many relationship on the SQLAlchemy ORM back referencing to the same attribute?…