【问题标题】:Keep recieving TypeError when construction Pony ORM db.Entity object构造 Pony ORM db.Entity 对象时不断收到 TypeError
【发布时间】:2021-03-10 10:10:56
【问题描述】:

我正在尝试使用 Pony ORM 将数据插入到 postgresql 数据库中,但是当我尝试使用 db.Entity 类构造对象时,我不断收到TypeError: Unknown attribute 'name'

有问题的类如下所示:

class Diet(db.Entity):
    name: Required(str)
    category: Set('Category')

这是创建类的地方:

    for d in data.category.diet:
        print(d)
        diets.append(
            Diet(
                name=d["name"]
            )
        )

我使用的是 Pony ORM 0.7.14 版

【问题讨论】:

    标签: python database postgresql ponyorm


    【解决方案1】:

    冒号必须是等号

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      • 2014-08-31
      • 1970-01-01
      • 2019-02-21
      • 2017-06-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多