Use savepoints per row to isolate failing inserts
This commit is contained in:
parent
f0fe6eba81
commit
2215067987
@ -121,6 +121,7 @@ def main():
|
||||
continue
|
||||
|
||||
try:
|
||||
sp = conn.begin_nested()
|
||||
conn.execute(text("""
|
||||
INSERT INTO servers
|
||||
(hostname, fqdn, domain_ltd, os_family, os_version, machine_type,
|
||||
@ -139,11 +140,14 @@ def main():
|
||||
responsable_nom = EXCLUDED.responsable_nom,
|
||||
patch_owner_details = EXCLUDED.patch_owner_details
|
||||
"""), params)
|
||||
sp.commit()
|
||||
inserted += 1
|
||||
if ip:
|
||||
ip_map.append((hostname, ip))
|
||||
except Exception as e:
|
||||
print(f" [ERR] {hostname}: {e}")
|
||||
try: sp.rollback()
|
||||
except Exception: pass
|
||||
print(f" [ERR] {hostname}: {str(e)[:200]}")
|
||||
skipped += 1
|
||||
|
||||
if not args.dry_run:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user