pythondatabasepostgresqlponyorm

Keep recieving TypeError when construction Pony ORM db.Entity object


I'm trying to insert data into a postgresql database using Pony ORM but when I try to construct an object using a db.Entity class I keep receiving TypeError: Unknown attribute 'name'

The class in question looks as followed:

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

This is where the class get created:

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

I'm using Pony ORM version 0.7.14


Solution

  • The colon has to be an equals sign