Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
-1 votes
0 answers
18 views

Alternative to slow SRF in SELECT?

I have the following case select my_srf_func(otherfunc(h)) from (values (‘…’::mytype), ‘…’::mytype), (‘…’::mytype), ‘…’::mytype), (‘…’::mytype),...
user avatar
0 votes
0 answers
16 views

How to define a shared/initialization code block in postgres PL/python?

I understand that in PL/python3 (PostgreSQL 14), I can define a SQL function in which the function body is written in python. For example, CREATE OR REPLACE FUNCTION my_func(a text) RETURNS text ...
user avatar
  • 2,807
0 votes
1 answer
219 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 not ...
user avatar
0 votes
1 answer
26 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, ...
user avatar
  • 133
0 votes
1 answer
23 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']) ...
user avatar
0 votes
2 answers
1k views

Unable to install pl/python for Postgresql12

To get the obvious out of the way, my question is posted after reading many other questions like this one https://stackoverflow.com/questions/60683776/install-pl-python-on-windows-for-postgresql-12 ...
user avatar
4 votes
2 answers
1k 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 ...
user avatar
0 votes
0 answers
45 views

Ubuntu PostgreSQL - Upgrade adding Python extension

I have an existing and populated PostgreSQL 10 instance, to which I'd like to add Python support as a Procedural language. As far as I can tell this can be done initially by installing postgresql and ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
  • 101
0 votes
1 answer
45 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 ...
user avatar
  • 103
1 vote
1 answer
301 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 ...
user avatar
  • 181
1 vote
3 answers
626 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 ...
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
  • 121
1 vote
1 answer
127 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....
user avatar
  • 1,331
3 votes
1 answer
148 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 ...
user avatar
1 vote
0 answers
163 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) ...
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 ...
user avatar
0 votes
1 answer
224 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('...') $_$; ...
user avatar
  • 1,331
0 votes
0 answers
275 views

What role for plpythonu function's in the file system?

As a preliminary test for a further work I'm trying to use a simple plpythonu function in Postgresql 9.2 to create a folder in my filesystem. So I have this code : CREATE OR REPLACE FUNCTION "...
user avatar
  • 171
1 vote
0 answers
210 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 ...
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 ...
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 ...
user avatar
1 vote
1 answer
522 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: ...
user avatar
  • 131
15 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 (...
user avatar
4 votes
1 answer
8k 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 ...
user avatar