The scope of a conflict resolution clause always is the current statement, not any following statements.
This works as documented.
It is common for programs, when they encounter an error, to fix whatever caused the error and to retry the statement, or to execute another statement.
Therefore, the database assumes that any command that you execute is a command that you actually want to execute.
The ON CONFLICT ROLLBACK clause does not make sense for your application.
You should use the normal ON CONFLICT ABORT algorithm, and either handle conflicts by not executing any following commands:
try:
db.execute("BEGIN")
db.execute("INSERT INTO places(place) VALUES(17)")
db.execute("INSERT INTO places(place) VALUES(18)")
db.execute("INSERT INTO places(place) VALUES(19)")
db.execute("COMMIT")
except:
db.execute("ROLLBACK")
or insert all values in a single statement so that any ABORT automatically rolls back the other values:
INSERT INTO places(place) VALUES (17), (18), (19)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…