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.
Questions tagged [plpython]
28 questions
17
votes
3 answers
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 (in overhead) how Postgres call / manage plpython…
Robert Zaremba
- 273
- 2
- 6
13
votes
1 answer
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 variant plpython might become available in the…
foobar0100
- 641
- 7
- 15
6
votes
2 answers
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 wondering is, when or why would anyone need to use this?…
Chessbrain
- 1,223
- 3
- 17
- 25
4
votes
1 answer
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 when my db_user tries
create function…
Stephane Rolland
- 8,911
- 11
- 33
- 40
3
votes
1 answer
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 supported by
Amazon RDS Detail: Installing the extension…
SQLSERVERDAWG
- 141
- 1
- 3
- 9
3
votes
1 answer
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 function (written in PL/Python):
CREATE OR REPLACE…
Robin Koch
- 153
- 4
3
votes
1 answer
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 custom module from plpythonu?
I can't guarantee…
spencerrecneps
- 373
- 1
- 4
- 14
3
votes
1 answer
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 old and B) requires me to separate the components…
spencerrecneps
- 373
- 1
- 4
- 14
2
votes
1 answer
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 so. I am well aware of SQL injection and the…
wfgeo
- 191
- 1
- 5
2
votes
0 answers
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, it seems that I cannot create the plpython3u…
user143369
1
vote
1 answer
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:
plpy.notice("Hello World")
$$ LANGUAGE…
q9f
- 131
- 1
- 1
- 5
1
vote
0 answers
Any issues with EDB Postgres, plpython3u, Psycopg on Apple Silicon?
I currently have an old Intel i7 based iMac. I plan to upgrade to the M4 Mac Mini (Apple silicon).
I am running Postgres and use plPython (plpython3u) internally for procedures and triggers. Externally I use psycopg to access the DB from Python. I…
Crashmeister
- 161
- 6
1
vote
1 answer
How to improve custom aggregate function performance & identify bottlenecks
This is a continuation of a question I asked on the best way to compute statistics on a list of rows unique per column, which can be found here (along with the table schema)
I have a table, which holds millions of rows of stock data and I want to…
Eoin Fitzpatrick
- 13
- 4
1
vote
3 answers
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 install I did 'pip3 install yaml' which worked fine.
How…
Crashmeister
- 161
- 6
1
vote
1 answer
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.execute(
'''SELECT current_setting FROM…
guettli
- 1,591
- 5
- 25
- 51