This commit is contained in:
2025-10-06 22:08:23 +02:00
parent e04e65f665
commit 51563e2dcd
7 changed files with 371 additions and 9 deletions

View File

@@ -1,25 +0,0 @@
DO $$
DECLARE
f TEXT;
BEGIN
FOR f IN SELECT pg_catalog.pg_ls_dir('/tmp/json')
LOOP
IF right(f, 5) = '.json' THEN
BEGIN
RAISE NOTICE 'Import du fichier : %', f;
INSERT INTO item (id, caracteristiques)
VALUES (
replace(f, '.json','')::bigint,
pg_read_file('/tmp/json/' || f)::jsonb
)
ON CONFLICT (id) DO UPDATE
SET caracteristiques = EXCLUDED.caracteristiques;
EXCEPTION WHEN OTHERS THEN
RAISE WARNING 'Erreur lors de l''import du fichier % : %', f, SQLERRM;
END;
END IF;
END LOOP;
END;
$$ LANGUAGE plpgsql;