Questions tagged [plpython]

An extension which allows one to write Python-based triggers and functions inside of the PostgreSQL RDBMS. Use this tag for questions about PostgreSQL's PL/Python Procedural Language.

Filter by
Sorted by
Tagged with
0 votes
0 answers
122 views

how to import the plpy module for postgres PL/python3u?

In PL/python3u code, I understand that there are Database Access Functions such as plpy.execute(), which can be used directly inside a database function of type LANGUAGE plpython3u. Is it possible to ...
tinlyx's user avatar
  • 3,325
0 votes
0 answers
41 views

PostgreSQL: Python UDF not shown in query plan obtained by EXPLAIN ANALYZE

I have a question regarding the execution of a Python UDF. Let's suppose I have a UDF named testUDF(...) and I apply it to table "testtable". When I run the query SELECT testUDF(...) from ...
KSV97's user avatar
  • 3
2 votes
1 answer
2k views

Extension "plpythonu" is not supported by Amazon RDS

I am trying to install extension "plpython3u" that supports writing python in postgresql. CREATE EXTENSION plpython3u; Error: SQL Error [22023]: ERROR: Extension "plpythonu" is ...
SQLSERVERDAWG's user avatar
0 votes
1 answer
142 views

Can you run PL/Python or PL/v8 code from the database itself?

It it possible to run code that is stored in the database, on the database. For example, I'd like a trigger to execute a function whose Javascript code is stored in the same database. (Normally, ...
fadedbee's user avatar
  • 133
0 votes
1 answer
168 views

Passing a python list into plpy execute for the in operator without string interpolation

I have a plpython query for an 'in' where clause user_ids = [1,2,3] query = "SELECT department from users where id in ($1)" prepared_query = plpy.prepare(query, ['bigint']) ...
Chris Mccabe's user avatar
4 votes
2 answers
3k views

When (or why even) use PLPython(3)u

As I gain more experience with PostgreSQL I start to question the existence of PLPython. It's considered an "untrusted" language https://www.postgresql.org/docs/10/plpython.html What I am ...
Chessbrain's user avatar
  • 1,163
0 votes
1 answer
76 views

Is there an efficient way to use 3rd party packages in PL/Python?

I've found examples of people importing 3rd party packages into PL/Python scripts, but it seems to me that re-importing libraries upon every run of a stored procedure is terribly inefficient. Does ...
feuGene's user avatar
  • 101
0 votes
1 answer
165 views

how can I divide log files for specific DB queries?

Currently my db has a couple of triggers for some (not all) tables that get executed when a specific number of columns has been updated. I keep track if the triggers for those rows on a boolean column ...
Eiron's user avatar
  • 103
1 vote
1 answer
453 views

Can plpython3u open files on the file system?

I am trying to write a plpython3u function that should open a file in the file system and read some values out of it that get returned by a query. But I am getting a permission denied error when doing ...
wfgeo's user avatar
  • 181
1 vote
3 answers
843 views

How to get YAML Python Library in PostgreSQL

I would like to use YAML in some plpython code, but YAML is not included in the python3 extension for PostgreSQL. My 'import yaml' gets an error that it cannot find yaml. On my regular Python3 ...
Crashmeister's user avatar
2 votes
0 answers
1k views

installing plpython3u for postgresql 9.6 under windows 7

I've used EnterpriseDB stackbuilder to install postgres9.6 and the language-pack. Postgres9.6 is installed under C:\Program Files folder while the edb lanaguge pack is installed under C:\edb. However,...
user avatar
1 vote
1 answer
171 views

plpythonu: Read

The application "foo" uses this plpythonu source code to read the custom variable foo.transaction_id. I guess this is way too complicated. How to shorten/simplify below lines? txid_list = list(plpy....
guettli's user avatar
  • 1,421
3 votes
1 answer
168 views

Preparing CREATE statement

I try to have a view created on the fly. In my case it's a pivot view on a EAV-style table. Assuming a table which contains two attributes I use a statement like this, executed inside of a trigger ...
Robin Koch's user avatar
1 vote
0 answers
190 views

pypl store function to update a record is not working

I am using PostgreSQL 9.4.7 and Python 2.7.6. I am writing a plpython function to update a row in user table and my code is as below: CREATE FUNCTION update_user(myid int, mymail text, myname text) ...
xcoder's user avatar
  • 11
13 votes
1 answer
3k views

Why is PL/Python untrusted?

According to the docs: PL/Python is only available as an "untrusted" language, meaning it does not offer any way of restricting what users can do in it and is therefore named plpythonu. A trusted ...
foobar0100's user avatar
0 votes
1 answer
254 views

plpy.execute('...') statements not in logs

How can I get the SQL statements executed by plyp into the postgres log files? CREATE FUNCTION history_monitor() RETURNS trigger LANGUAGE plpythonu AS $_$ ... plpy.execute('...') $_$; ...
guettli's user avatar
  • 1,421
1 vote
0 answers
218 views

Require Language In PostgreSQL Extension Control File

I'm developing a custom extension that uses plpythonu in several functions. I'd like to be able to require that plpythonu be installed in order to create my extension, but I don't see anything in the ...
spencerrecneps's user avatar
3 votes
1 answer
1k views

Custom modules for plpythonu

I'm writing a series of plpythonu functions which share a few common bits of code. I'd like to package the shared code into a separate module for ease of maintenance. Is there an easy way to call my ...
spencerrecneps's user avatar
2 votes
1 answer
5k views

How to return multiple columns (each a composite type) in plpythonu

I have created a plpythonu function that should return a table with multiple columns. At present, it returns a single column with multiple components. I came across this answer which is A) a little ...
spencerrecneps's user avatar
1 vote
1 answer
563 views

How to use language PL/PythonU on a PostgreSQL database via phpPgAdmin?

I am used to PgAdmin III where I can simply create python functions like the following on a PostgreSQL database: CREATE OR REPLACE FUNCTION pyHello (x integer) RETURNS void AS $$ if x == 1: ...
q9f's user avatar
  • 131
17 votes
3 answers
7k views

PostgreSQL procedural languages overhead (plpython / plsql / pllua...)

I'm trying to find information about PostgreSQL user defined functions in procedural languages performance for real time tasks. How does they compare to builtin functions? Is there any difference (...
Robert Zaremba's user avatar
4 votes
1 answer
10k views

Cannot `create function` in plpython3u, permission denied

As postgres user, I have create extension plpython3u; in my database then I have set the plpython3u to trusted: select lanpltrusted from pg_language where lanname like 'plpython3u'; returns true but ...
Stephane Rolland's user avatar