Questions tagged [plpython]

Questions about PostgreSQL's PL/Python procedural language. This extension allows one to write python-based triggers and functions inside of the PostgreSQL RDBMS.

166 questions
0
votes
0 answers

calling plpy.execute in PL/Python much slower than calling Execute in PL/pgsql

I have written the same function in PL/PgSQL and PL/Python: create function pythontest2() returns TABLE(id bigint, timestamp_ timestamp without time zone, acknowledgedtimestamp timestamp without time zone, inactivetimestamp timestamp without…
Adam Van Oijen
  • 435
  • 3
  • 8
  • 17
0
votes
0 answers

Need to transform this mysql function into redshift function or stored procedure

so i have an mysql function that i need to convert to a procedure or function that is compatible with aws redshift. This is the mysql function: CREATE DEFINER=`software`@`%` FUNCTION `redeemed_qty`(ticketID bigint) RETURNS bigint BEGIN …
0
votes
0 answers

how to resolve this backend error when using plpython in SQL

I'm using postgres 14 for creating this function in Datagrip: CREATE EXTENSION plpython3u; CREATE OR REPLACE FUNCTION pymax (x integer, y integer) RETURNS integer AS $$ if x>y: return x $$ LANGUAGE plpython3u; The user I…
algorythms
  • 1,547
  • 1
  • 15
  • 28
0
votes
0 answers

Plpython3u breaking encoding on execute

Environment: Debian 11 with pl_PL locale(ISO-8859-2) Postgresql 13 database created with ISO 8859-2 encoding Plpython3u(Python 3.9.2) A simple example of the problem: CREATE OR REPLACE FUNCTION public.test() RETURNS TEXT LANGUAGE plpython3u AS…
Zadieln
  • 1
  • 1
0
votes
0 answers

Problem to update postgres table column values using TD["new"] from update trigger function written in plpython3u

I am facing problems in updating column values from the postgresql trigger function written in plpython3u using TD['new']. All the other statements before and after the TD['new'] assignments are executed properly, no exception or error is generated…
0
votes
1 answer

postgreSQL pl/python how do I get the RETURNING from a query?

in this (vey condensed) query, how would one return the myfile_key from RETURNING? CREATE OR REPLACE FUNCTION myfunction (src int, OUT result int) AS $$ plan = plpy.prepare("INSERT INTO myfile VALUES (nextval('seq_myfile'),$1,$2) RETURNING…
DrLou
  • 649
  • 5
  • 21
0
votes
2 answers

Greenplum Database : enabling PL/Python module

I'm on Version 6.6.14 of Greenplum and trying to enable python 3. When I try to enable it with this command: CREATE LANGUAGE plpython3u; I get the following error: ERROR: could not access file "$libdir/plpython3": No such file or directory Any I…
0
votes
1 answer

time.sleep() has 60 sec limit in plpythonu?

Note: I'm running Postgres 11.7 and Python 2.7.17. It appears that time.sleep() has 60 sec limit in plpythonu function. It works as expected up to 60 seconds. But if passed a value greater than 60 then it stops at 60 seconds. CREATE OR REPLACE…
JohnMudd
  • 13,607
  • 2
  • 26
  • 24
0
votes
1 answer

How can i Call restFull API in PostgreSQL

I am using PostgreSQL 12.6, compiled by Visual C++ build 1914, 64-bit on Windows Server. And like to know how can I call RestFull API using python or perl in postgres. I am relatively new in call restFull API from postgres so I will need a step by…
Jay Mehta
  • 13
  • 3
0
votes
1 answer

Confused about strange import behavior within plpython stored procedures

I'm running Postgresql 9.4, and I'm confused about how it handles plpython imports, specifically regarding Decimal. First example: CREATE OR REPLACE FUNCTION devel.foo() RETURNS void AS $BODY$ def myfoo(): …
0
votes
1 answer

Can I pass a variable through $1 to a "NOTIFY" command in PostgreSQL?

I have the following working code : CREATE EXTENSION IF NOT EXISTS plpython3u; UPDATE pg_language SET lanpltrusted = true WHERE lanname LIKE 'plpython3u'; CREATE OR REPLACE FUNCTION test_notif_trigger_function() RETURNS trigger AS $$ updateQuery =…
Krophil
  • 21
  • 5
0
votes
1 answer

How to run multiprocess on a windows server with pl/python 3?

I am running a trigger function on INSERT/UPDATE that would create a new process that sends a post request to an api. on a Ubuntu + PostgresQL 12 docker container running I was able to get the new process to form without an issue with the below…
Denis S Dujota
  • 543
  • 5
  • 13
0
votes
1 answer

Running system command in Postgres and use return value in Insert

I have a linux command that i want to run in following function: CREATE FUNCTION tarifador_func2() RETURNS TRIGGER LANGUAGE plsh AS $$ #!/bin/sh SET userid[] = // here i want to run linux command and use that return value to insert into below…
ankit
  • 2,591
  • 2
  • 29
  • 54
0
votes
1 answer

Sending data from POSTGRESQL trigger to a python TCP server

I'm trying to monitor a table in postgres database. I want to send every operation on this table (INSERT OR UPDATE OR DELETE) to a python tcp server. So I tried to follow this tutorial, but without any success. Here's the SQL script I'm using…
No name
  • 323
  • 4
  • 11
0
votes
1 answer

PostgreSQL, plpython3u function. os.getenv does not find the environment variable

I get the below situation with PostgreSQL plpython3u function. I've recently added a environment variable to my shell startup file. The env | grep MY_VAR command returns MY_VAR=/path/. But when I run a select * from my_func(); query from a psql…