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
1 answer

Return SETOF Points from plpython/Postgis

I would like to create a function in pl/python3 / postgis that returns a set of geometry records (for example points). I managed to create a dictionary with the coordinates of my points, but I can't figure out how to turn them into actual postgis…
Stefan F
  • 2,573
  • 1
  • 17
  • 19
1
vote
0 answers

Access PostgreSQL large objects with pl/python

Is it possible to access PostgreSQL large objects with pl/python using the client interface function for large objects? Just calling the server-side functions from within the pl/python using plpy.execute seems rather limited.
sivann
  • 2,083
  • 4
  • 29
  • 44
1
vote
1 answer

How to upgrade Postgres93.app

I have Postgres93.app installed (version 9.3.1), and cannot enable or run PLPython, presumably because of this: https://github.com/PostgresApp/PostgresApp/issues/150. How do I upgrade to the latest PostgresXX.app version and preserve my existing…
James Haskell
  • 1,545
  • 2
  • 16
  • 21
1
vote
1 answer

plpython get all rows on INSERT TRIGGER

I'm trying to implement something similar to replication with python trigger procedures. procedure CREATE OR REPLACE FUNCTION foo.send_payload() RETURNS trigger AS $$ import json, zmq try: payload = json.dumps(TD) ctx = zmq.Context() …
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
0
votes
1 answer

PLPython & CAST composite data type in Postgresql

I am writing a stored procedure in PlPython with a user defined type. I know Plpython does not support user defined types, so, I have created a CAST for the user defined type. Still I keep getting an error when I call plpy.prepare. I am not sure if…
rhm2012
  • 554
  • 1
  • 5
  • 8
0
votes
2 answers

PostgreSQL Procedure using python write dataframe to table

I am developing a PostgreSQL Procedure using the plpython3u extension which let you use python procedural language into PostgreSQL. With the following code using plpy, I am able to retrive data form table and put it into pandas dataframe. CREATE OR…
Stavros Koureas
  • 1,126
  • 12
  • 34
0
votes
0 answers

plpygis can't find shapely dependency

I have a problem with the plpygis library for python. Whenever I'm trying to convert a plpygis Point type into its shapely counterpart, I get the following error: ERROR: plpygis.exceptions.DependencyError: Dependency 'Shapely' is not available. The…
yarvis
  • 69
  • 1
  • 6
0
votes
1 answer

Use virtual environment for plpython3u in PostgreSQL

I'm trying to use packages from an existing virtual environment within the plpython3u extension for PostgreSQL. I found and followed this tutorial, but it didn't work. Firstly, the configuration file for my installation is named and looks different…
yarvis
  • 69
  • 1
  • 6
0
votes
1 answer

Update Redis cache value from PostgreSQL

I am working on a Python project and I have a requirement that whenever a row is inserted, updated, or deleted in a PostgreSQL table, the corresponding value should be updated in Redis. I am working on a Windows system and Redis is installed in a…
jps
  • 1
  • 2
0
votes
0 answers

call rest api from postgresql FUNCTION

I am trying to calling to call API from PostgreSQL function using PL/Python. When I call API it raised error and I searching from last two days to resolve the error but no success. Below is my function in PostgreSQL CREATE OR REPLACE FUNCTION…
user1891251
  • 41
  • 1
  • 1
  • 12
0
votes
0 answers

I am getting same error again and again after installing requests library in postgresql while using plpython3u

do $$ import requests $$ language plpython3u; Error : SQL Error [38000]: ERROR: ModuleNotFoundError: No module named 'requests' Where: Traceback (most recent call last): PL/Python anonymous code block, line 3, in import requests PL/Python…
0
votes
0 answers

Using dask delayed function from within postgresql plpython with "plpy.execute"

The below example demonstrates using dask delayed funtions (ref) from within postgres plpython while using "plpy.execute" (ref) to query the database. It returns an error: ERROR: spiexceptions.StatementTooComplex: stack depth limit exceeded Any…
Shadi
  • 9,742
  • 4
  • 43
  • 65
0
votes
0 answers

plpy.info doesn't display output in sqlalchemy

This query run with psql psql -c 'DO LANGUAGE plpython3u $$ import sys; plpy.info(sys.path) $$' displays INFO: ['/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages',…
Shadi
  • 9,742
  • 4
  • 43
  • 65
0
votes
1 answer

Can pl/python be used to write postgres functions in an azure hosted db?

Is it possible to write postgres functions in pl/python on an azure hosted db? Postgres allows python, but I read that creating python functions requires superuser; however, I also read that azure postgres does not expose superuser account.
Peter Rilling
  • 323
  • 3
  • 7
0
votes
1 answer

select a specific row for each group according to a custom logic

I have the following table: create table test_table ( id serial primary key, store text, price int, id_2 text); insert into test_table (store, id_2, price) values ('a', '11', 100), ('b', '22', 120), ('c', '33', 150), ('d', '33',…
matrs
  • 59
  • 1
  • 6