Problem with python in postgres on mac

0

People, I'm testing trigger functions with python in Postgres and I'm having problems when I test on my Mac. Here's the function:

create function sendchange()
returns trigger
as $$
import requests
import json

url = "http://localhost:8080/send"
headers = {'Content-Type': 'application/json'}

payload = {'source': TD['args'][0], 'table': TD['args'][1], 'data': TD['new']}
r = requests.post(url, data=json.dumps(payload), headers=headers)
$$ language plpythonu;

And the trigger creation:

CREATE TRIGGER insertteste AFTER INSERT
ON processo FOR EACH ROW
EXECUTE PROCEDURE sendchange ('application','usuario');

It happens that, in windows environment, the trigger works without any problem. But when I try on Mac, the error is thrown:

SQL state: 38000
Context: Traceback (most recent call last):
PL/Python function "sendchange", line 2, in <module>
import requests
PL/Python function "sendchange"

I have no idea why this is happening in the Mac Linux environment. This script is to send data from the database to another application.

    
asked by anonymous 22.11.2018 / 13:58

0 answers