如何使用SQLAlchemy将新节点添加到使用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)
我需要在表上使用一个触发器来为新节点分配lft
和{
您可能需要查看SQLAlchemy的examples目录中的nested sets example。这在Python级别实现了模型。在
使用触发器在数据库级别执行此操作需要某种方式来通信所需的父级,可以作为额外的列,也可以作为存储过程。在
相关问题 更多 >
编程相关推荐