如何从 postgresql 函数或触发器发送一些 http 请求
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3325292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I send some http request from postgresql function or trigger
提问by im4LF
I need to send data via http protocol (GET or POST request) from the function or trigger. Is it possible?
我需要从函数或触发器通过 http 协议(GET 或 POST 请求)发送数据。是否可以?
采纳答案by Kevin
You could try writing the trigger in PL/Python and use urllib2 to POST.
您可以尝试在 PL/Python 中编写触发器并使用 urllib2 进行 POST。
回答by Sean
回答by Craig Ringer
Any "untrusted" language with HTTP support can do this:
任何支持 HTTP 的“不受信任”语言都可以这样做:
- PL/Pythonu
- PL/perlu
- PL/javau
- ...
- PL/Pythonu
- PL/秘鲁
- PL/爪哇
- ...
but you shouldn't really do it. See Does PLV8 support making http calls to other servers?and why you shouldn't send email from a trigger function.
但你真的不应该这样做。请参阅PLV8 是否支持对其他服务器进行 http 调用?以及为什么不应该从触发器函数发送电子邮件。