如果不存在 Peewee 插入

Afr*_*lam 11 python peewee

我使用 Python/Mysql 和 Peewee 作为 ORM。我陷入了困境。假设我想使用 peewee 插入一行,但检查该行是否存在跳过其他插入。是否有任何程序可以使用 peewee 在 python 中执行此操作。

kha*_*mel 11

不确定你已经尝试过什么,但我建议使用peewee的Model.get_or_create()Model.create_or_get()方法来做你正在寻找的东西: Peewee Get 或 Create