python - Peewee 插入如果不存在

标签 python peewee

我正在使用 Python/Mysql 和 Peewee 作为 ORM。我陷入困境。假设我想使用 peewee 插入一行,但检查该行是否存在,否则跳过插入。在使用 peewee 的 python 中是否有任何程序可以这样做。

最佳答案

不确定您已经尝试过什么,但我建议使用 peewee 的 Model.get_or_create()Model.create_or_get() 方法来执行您的操作'正在寻找:Peewee Get or Create

关于python - Peewee 插入如果不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30977577/

相关文章:

python - peewee.配置不当 : Postgres driver not installed

python - 从 Peewee 的列中选择不同的值

python - (Python) - Peewee - 如何创建外键

python - Python 中的时区转换

python - 在 python 上使用 selenium 打开多个网站

python - 如何访问 GridSearchCV 中的 ColumnTransformer 元素

python - Peewee、MySQL 和插入忽略

python - 查询多对多字段

python - Pandas:编辑索引值并根据新值重新分组

orm - order_by() 方法在 peewee 中不起作用