检查PrimaryKey是否与ponyorm一起存在

时间:2015-07-08 09:14:38

标签: python ponyorm

我正在尝试使用pony orm来查看是否存在主键。我做到了这一点,但总是会出错。

class Favorite(db.Entity):
    game = Required(Game)
    user = Required(User)
    date_favorited = Required(datetime)
    PrimaryKey(user, game)

这是函数

    if Favorite.get(lambda: user, game) is not None:
        favorited = 1

这是错误的

TypeError: The second positional arguments should be globals dictionary. Got: Game[12]

1 个答案:

答案 0 :(得分:1)

github repo

中得到了帮助
if Favorite.exists(user=x, game=y):
    favorited = 1