Save validated records within a database transaction
huddlej opened this issue · 1 comments
huddlej commented
Instead of saving records in a try/except block and deleting all saved records when a save fails, use a database transaction for all saves and only commit the transaction when all saves complete successfully.
Users with MySQL MyISAM tables will need to convert to InnoDB tables to get transactions. The default table engine can be set in Django's settings:
DATABASE_OPTIONS = {
"init_command": "SET storage_engine=INNODB",
}