取决于数据库。
对于Postgresql,peewee 3.x完全支持ON CONFLICT子句。请注意,您可以将“on_conflict”api与SQLite和MySQL一起使用,限制是它们不支持“UPDATE”操作。见文件:http://docs.peewee-orm.com/en/latest/peewee/api.html#OnConflict
示例:# Works with SQLite and MySQL (which use "REPLACE")
result = (Emp
.insert(first='mickey', last='dog', empno='1337')
.on_conflict('replace')
.execute())
# Works with Postgresql (which supports ON CONFLICT ... UPDATE).
result = (Emp
.insert(first='foo', last='bar', empno='125')
.on_conflict(
conflict_target=(Emp.empno,),
preserve=(Emp.first, Emp.last),
update={Emp.empno: '125.1'})
.execute())