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