Questions about PostgreSQL's PL/Python procedural language. This extension allows one to write python-based triggers and functions inside of the PostgreSQL RDBMS.
Questions tagged [plpython]
166 questions
0
votes
1 answer
How to make PL/Python tracebacks more verbose?
Currently in case of error I have such traceback in psql for PL/Python procedure, that imports Python module and calls some function from it:
ERROR: AssertionError:
CONTEXT: Traceback (most recent call last):
PL/Python function…

Gill Bates
- 14,330
- 23
- 70
- 138
0
votes
1 answer
PL/Python: How to return an empty set?
I have a function that operates on int[]. I want to have the ability to check if the array is empty and in that case to stop since there is nothing to do.
this is my funcion:
CREATE OR REPLACE FUNCTION func2(c integer[])
RETURNS SETOF func_type…

John
- 1,724
- 6
- 25
- 48
0
votes
1 answer
Is it possible to maintain state between Postgres trigger invocations?
I am implementing a trigger in PostgreSQL using Python that
sends an AMQP message via amqpy.
A connection is required to send the message. Currently,
the only way I know to do this is, when the trigger is
invoked, open a connection, send the…

user1062589
- 177
- 2
- 11
0
votes
0 answers
Inserted row in PostgreSQL are not available in trigger function
database : postgresql
language : plpythonu
topic: trigger function
create trigger request_received_trigger
after insert on req_table
for each row
execute procedure request_received_function();
I need to do something after every insert but…

mehdi
- 2,703
- 1
- 13
- 15
0
votes
0 answers
Error in postgresql func with datatype
I have a function created as follows:
CREATE LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION unpickle (data text)
RETURNS text[]
AS $$
import base64
import pickle
return pickle.loads(base64.b64decode(data))
$$ LANGUAGE plpythonu…

jethar
- 2,223
- 2
- 22
- 19
0
votes
2 answers
PostgreSQL trigger with a given role
I made a little PostgreSQL trigger with Plpython. This triggers plays a bit with the file system, creates and delete some files of mine. Created files are owned by the "postgres" unix user, but I would like them to be owned by another user, let's…

azmeuk
- 4,026
- 3
- 37
- 64
0
votes
0 answers
Could not install Pl/pythonu (Windows 8.1)
I am using postgreSQL v9.3 on Windows 8.1 64x. Failed to create extension plpythonu:
ERROR: could not access file "$libdir/plpython2": No such file or directory
How i can resolve it?

v.chjen
- 615
- 1
- 8
- 20
0
votes
2 answers
SyntaxError: invalid syntax ()
I have python 2.7 and I have weather script which returns temperature infos, I would like to implement this script into PostgreSQL. I always got this error: DETAIL: SyntaxError: invalid syntax (, line 10)
code:
CREATE OR REPLACE…

Balazs
- 117
- 1
- 3
- 14
0
votes
2 answers
plpython setup windows 8
I am trying to set up plypython on the following system:
Windows 8.1
PostgreSQL 9.2 64-bit
Python 2.7.05
When I run:
CREATE EXTENSION plpython2u;
I get:
ERROR: could not load library "C:/Program Files/PostgreSQL/9.2/lib/plpython2.dll": %1 is…

DGraham
- 705
- 2
- 10
- 23
0
votes
1 answer
Storing the query result in a list variable in plpython function
I am very new to postgresql and writing functions so bear with me. I need to transform a Python script into a postgresql function and I intend to use PL/Python for the purpose. However I am having some problems in doing so. When executing the…

Kaisa
- 7
- 4
0
votes
1 answer
Where I can find my PLPython functions in Postgres?
I've created some functions in a specific schema, but the "Functions" section has nothing inside..
I create functions like this example:
CREATE FUNCTION pymax (a integer, b integer)
RETURNS integer
AS $$
if a > b:
return a
return b
$$ LANGUAGE…

Gabriel Cavalcante
- 111
- 4
0
votes
0 answers
PL/Python error when parametrizing a create table
I am running a bunch of cleanup scripts that are parametrized by dates on PostgreSQL 8.3 database.
I am just trying to parametrize a bunch of code with a couple of date variables and testing the create table gives me the following error:
WARNING: …

user7980
- 703
- 3
- 15
- 28
0
votes
2 answers
PL/Python or Psycopg2
I have a Postgresql 9.1 server, and I want to write some functions on Python.
There 2 ways: plpy or psycopg2. For me writing functions in plpy is like nightmare, a lot of "prepare" and "execute" methods... more comfortably to use psycopg2, but I…

Zhas
- 21
- 1
-1
votes
1 answer
How to implement PostgreSQL function which gets the whole row?
For instance I want to count null fields for each row in a table.
What argument type declaration should I use?
I tried composite type (table name as a type):
CREATE FUNCTION count_null (row my_table)
RETURNS INTEGER
AS $$
return len([x for x in…

Leonid Shvechikov
- 3,927
- 2
- 17
- 14
-2
votes
1 answer
How to run a script on startup in PostgreSQL?
I tried to create a pgAgent Job, but I can't seem to make it work the way I want. I can schedule a maintenance and put my script there, but it is not exactly what I want to do.
To be more precise, what I want to do is to start a script that will…

Dave
- 39
- 5