23

I need to send data via http protocol (GET or POST request) from the function or trigger. Is it possible?

lospejos
  • 1,976
  • 3
  • 19
  • 35
im4LF
  • 275
  • 1
  • 4
  • 10

3 Answers3

16

You could try writing the trigger in PL/Python and use urllib2 to POST.

Kevin
  • 3,391
  • 5
  • 30
  • 40
  • Hmm, it looks like a PL/Perl in untrusted mode (http://www.postgresql.org/docs/8.4/interactive/plperl-trusted.html)... Are there differences in the use of PL/Python and PL/Perl? Both of then must be runned in untrusted mode and thats all? This means that I can use the module IO::Socket or HTTP::Request without any limitations? – im4LF Jul 24 '10 at 17:37
10

There is an extension to do this, use with caution.

pgsql-http

Sean
  • 321
  • 3
  • 6
4

Any "untrusted" language with HTTP support can do this:

  • PL/Pythonu
  • PL/perlu
  • PL/javau
  • ...

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.

Community
  • 1
  • 1
Craig Ringer
  • 307,061
  • 76
  • 688
  • 778