Files
sql/json/json.sql

23 lines
542 B
MySQL
Raw Normal View History

2025-09-17 01:37:38 +02:00
create table item (
id bigint primary key,
caracteristiques jsonb
);
DO $$
DECLARE
f TEXT;
BEGIN
FOR f IN SELECT pg_catalog.pg_ls_dir('/tmp/json')
LOOP
IF right(f, 5) = '.json' THEN
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;
END IF;
END LOOP;
END;
$$ LANGUAGE plpgsql;