Nested dialing model and SQLAlchemy - adding new nodes

How to add new nodes using SQLAlchemy to a tree implemented using the Nested Set Model ?

class Category(Base):
    __tablename__ = 'categories'

    id = Column(Integer, primary_key=True)
    name = Column(String(128), nullable=False)
    lft = Column(Integer, nullable=False, unique=True)
    rgt = Column(Integer, nullable=False, unique=True)

I need a trigger in the table to assign lftboth a rgtnew node and update all other vulnerable nodes, but what is the best way to determine the position of a node? I can pass the parent_idnew node to the constructor, but how then will I pass the parent_idtrigger?

+3
source share
1 answer

, SQLAlchemy. Python.

, .

+6

Source: https://habr.com/ru/post/1713602/


All Articles