From cfa771a83062076626d574cbb4cba30ac35964a8 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Sat, 19 Jul 2025 11:31:52 +0200 Subject: [PATCH] Skip info for saillines with no preplot. It may happen that the sailline info file has data for more lines than are actually in the preplot (e.g., if importing a reduced preplot file). In this case, we don't want a constraint violation error due to missing corresponding lines in `preplot_lines` so we check for that and only import lines that do exist in `preplot_lines` --- bin/datastore.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bin/datastore.py b/bin/datastore.py index 56ceb08..5578185 100644 --- a/bin/datastore.py +++ b/bin/datastore.py @@ -274,11 +274,27 @@ class Datastore: with self.conn.cursor() as cursor: cursor.execute("BEGIN;") + # Check which preplot lines we actually have already imported, + # as the line info file may contain extra lines. + + qry = """ + SELECT line, class + FROM preplot_lines + ORDER BY line, class; + """ + cursor.execute(qry) + preplot_lines = cursor.fetchall() + hash = self.add_file(filepath, cursor) count=0 for line in lines: count += 1 - print(f"\u001b[2KSaving line {count} / {len(lines)}", end="\r", flush=True) + + if not (line["sail_line"], "V") in preplot_lines: + print(f"\u001b[2KSkipping line {count} / {len(lines)}", end="\n", flush=True) + continue + + print(f"\u001b[2KSaving line {count} / {len(lines)} ", end="\n", flush=True) sail_line = line["sail_line"] incr = line.get("incr", True)