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
1
vote
0 answers

Install numpy to use within plpython3u in postgres 9.6 for Windows 2012 (64 bit)

I am trying to install numpy to use within plpython3u in postgres 9.6 for Windows 2012 (64 bit) but I run into dependency problems. 1) I have installed Postgres 9.6 from EnterpriseDB and the language pack, which automatically installs Python 3.3. …
PeterS
  • 139
  • 8
1
vote
1 answer

PostgreSQL: Set-returning function with single value in plpython3u

I want to write a plpython3u function in PostgreSQL that returns a set of texts. I've stumbled across a conundrum that looks strange to me. As per the manual, I can do the following: drop schema if exists X cascade; create schema X; create type…
John Frazer
  • 1,018
  • 13
  • 18
1
vote
0 answers

How do I perform a basic scipy gridddata interpolation using plpython?

Having trouble moving from plpython documentation example and griddata example to actual working code. Let us assume that 'my_table' has x, y, and z values for some simple reference grid where x,y pairs are point coordinates and z is the value at…
Brian D
  • 2,570
  • 1
  • 24
  • 43
1
vote
2 answers

PLPGSQL returned array, how to parse in Python?

I'm getting an array from plpgsql that looks like this: [0:2]={ "(ab023500-ceef-41d6-af33-635964dbffde,Koen,\"\",Schmeets,{koen@heizoo.com},31631205427},\"{\"\"Test…
Koen
  • 55
  • 1
  • 10
1
vote
2 answers

array function returning empty

The aim here is to adapt this answer to return array instead of setof datatype. CREATE FUNCTION split_csvline( line text, -- the input CSV string delim_char char(1) = ',', -- can be also E'\t', ';', '|', etc. quote_char…
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
1
vote
1 answer

Unique Count on Multiple Columns

I am on postgres/greenplum and I have a query result like this : e1 | e2 ------------------- | ------------------- 2017-01-01 00:00:00 | 2017-01-02 00:00:00 2017-01-01 00:00:00 | 2017-01-03 00:00:00 |…
gnuger
  • 305
  • 2
  • 12
1
vote
1 answer

How to access images with plpython using the pillow libary and saving on postgresql bytea column?

I have a problem accessing an image procesed from database stored as a bytea here is my pl to resize an image. CREATE OR REPLACE FUNCTION public.ajustar(randstring bytea) RETURNS bytea LANGUAGE plpythonu AS $function$ from io import BytesIO …
ncastrog
  • 31
  • 5
1
vote
1 answer

use Anaconda scikit-learn in PostgreSQL 9.5 plpython3u?

I wish to use scikit-learn Python machine learning library inside PostgreSQL plpython3u language functions. The easisest way to install scikit-learn (along with prerequisite NumPy and SciPy) is to install Anaconda. Anaconda comes with built-in…
zlatko
  • 596
  • 1
  • 6
  • 23
1
vote
1 answer

postgres 9.5 create function plpthon3u resets connections to server

I have installed postgresql 9.5 on windows 10, x64. I have created the extension plpython3u with python 3.3.5 on the server's path and it appeared to create the extension successfully: SELECT * FROM pg_available_extensions WHERE name like '%python%'…
pjc42
  • 233
  • 4
  • 9
1
vote
1 answer

Slow triggers checking primary key constraints with postgresql

I am trying to check primary key constraints along the inheritance tree in postgresql using a plpythonu trigger (check_pk). I'm using (PostgreSQL) 9.4.5. My question is why does the insert or update take at least 50 ms, when the execution of the…
jmaz
  • 81
  • 5
1
vote
1 answer

How are python functions compiled and stored in PostgreSQL?

Scenario: I have a python function on disk somewhere. I compile a plpythonu function in pg server, which is referencing that python function from step 1 on disk. I change something in python function (from step 1). If I compile plpythonu function…
M_M
  • 93
  • 6
1
vote
1 answer

langage plpython3u not allowed

I am working on debian jessie I have installed the language : aptitude install postgresql-plpython3 then : % createlang plpython3u template1 then : % psql postgres=# CREATE LANGUAGE plpython3u; I have tried this function : Create or replace…
user3554134
1
vote
1 answer

plpython, no such directory error in postgresql (ubuntu)

I installed the following package: sudo apt-get install postgresql-plpython-8.4 But while using: user=# create language plpythonu; Error is thrown: ERROR: could not access file "$libdir/plpython2": No such file or directory What am I missing…
DoOrDoNot
  • 1,132
  • 1
  • 10
  • 22
1
vote
1 answer

PostgreSQL how to append multiple results of execute query?

I have a function getitems(id) which gives all rows that are relevant for this id. I have a function in PostgreSQL named func1 which should return getitems over whole list of items: CREATE OR REPLACE FUNCTION func1(listof_id integer[]) RETURNS…
John
  • 1,724
  • 6
  • 25
  • 48
1
vote
1 answer

Can a plpython function take multiple rows as parameter?

I need to know that to make functions that take multiple rows of arrays and returns a result array. For example: Table some_table id | num_array 1 | [1,1,1] 2 | [2,2,2] Then running: SELECT custom_avg(num_array) FROM some_table; And get a an…
TigerShark
  • 43
  • 5