SQLAlchemy中对象的常量属性/列值

2 投票
1 回答
642 浏览
提问于 2025-04-16 17:35

我有一个类

class User:
    constant_value = 5

当我使用“mapper”时,这个属性就消失了。我该怎么做才能保留它呢?

1 个回答

0

使用 exclude_properties:

mapper(Address, addresses_table,
            exclude_properties=['street', 'city', 'state', 'zip'])

撰写回答