From 8b1e754ded4781ab86386ae87ae3b799099ff2d7 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 30 Jan 2026 05:08:06 +0000 Subject: [PATCH] MariaDB foibles, try to work around them --- parsers/survex.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/parsers/survex.py b/parsers/survex.py index 91ee573..f2a0917 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -12,6 +12,7 @@ from pathlib import Path from django.core.exceptions import ValidationError from django.db import connection +from django.db import transaction import troggle.settings as settings from troggle.core.models.caves import Cave, Entrance, GetCaveLookup @@ -2334,9 +2335,13 @@ class LoadingSurvex: qms_csv = QM.objects.filter(loaded_from_csv=True) # the CSV QMs print(f"\n - Currently {len(qms_svx)} survex QMs and {len(qms_csv)} CSV QMs", file=sys.stderr) - self.save_survexblocks_to_db() - self.save_personroles_to_db() - self.save_qms_to_db() + # Getting round MariaDB foibles: put these in different transactions + with transaction.atomic(): + self.save_survexblocks_to_db() + with transaction.atomic(): + self.save_personroles_to_db() + with transaction.atomic(): + self.save_qms_to_db() qms_n = QM.objects.all().count() print(f" - Now {qms_n} QMs in total", file=sys.stderr)