Postgres plpython2u请求get / post方法-如何传递参数?

问题描述

我使用此函数进行postgres api调用

CREATE OR REPLACE FUNCTION public.py_pgrest(p_url text,p_method text DEFAULT 'GET'::text,p_data text DEFAULT ''::text,p_headers text DEFAULT '{"Content-Type": "application/json"}'::text)
 RETURNS text
 LANGUAGE plpython2u
AS $function$
    import requests,json
    try:
        r = requests.request(method=p_method,url=p_url,data=p_data,headers=json.loads(p_headers))
    except Exception as e:
        return e
    else:
        return r.content
$function$;

我可以简单地称呼它

SELECT public.py_pgrest('http://***.comm/test.PHP');        

它也在击中服务器,所以我的问题是如何将参数传递到服务器中

我尝试了各种方式

SELECT public.py_pgrest('http://***.com/test.PHP','GET','{"name":"hello"}');

它不起作用你们是否知道如何传递参数?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)