Mise à jour d’une ancienne fonction plpython.
CREATE EXTENSION IF NOT EXISTS plpython3u;
CREATE OR REPLACE FUNCTION outils.get_api_json_response(
api_url text)
RETURNS json
LANGUAGE 'plpython3u'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
import urllib.request, ssl
context = ssl._create_unverified_context()
content=urllib.request.urlopen(api_url, context=context);
reponse = content.read().decode('utf-8')
content.close
return reponse
$BODY$;
SELECT outils.get_api_json_response('https://apicarto.ign.fr/api/cadastre/parcelle?code_insee=46263§ion=0A&numero=0692&source_ign=PCI')