plpython

Install PL/Python on Windows for PostgreSQL 12

老子叫甜甜 提交于 2021-02-11 05:32:09
问题 I've been working on FHIR for a project and we are using PostgreSQL as a database. While reading docs, I've come to know about PL/Python and decided to give it a shot but I am unable to install the python extension. When I run the command CREATE EXTENSION pypthon3u; I get the following error Could not load library "C:/Program Files/PostgreSQL/12/lib/plpython3.dll": The specified module could not be found. I've checked this SO answer but it couldn't help. My PostgreSQL version: PostgreSQL 12.2

postgres and python

我的未来我决定 提交于 2021-02-07 04:52:09
问题 In postgres 9.2 I am trying to create a python program that can be a trigger. I want to run an external program (an exe on the local disk) so I am using python to run it. When I try to create a simple program like this: CREATE FUNCTION one () RETURNS int AS $$ # PL/Python function body $$ LANGUAGE plpythonu; I get the error: ERROR: language "plpythonu" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. When I run: CREATE LANGUAGE plpythonu I get the error: ERROR:

Add plpython3 Extension to Postgres/timescaledb Alpine Docker Image

十年热恋 提交于 2020-12-29 09:57:47
问题 I try to add the plpython3 extension to my timescaledb / postgres (based on linux alpine) image: FROM timescale/timescaledb:0.9.0-pg10 RUN set -ex \ && apk add --no-cache --virtual .plpython3-deps --repository http://nl.alpinelinux.org/alpine/edge/testing \ postgresql-plpython3 When I try to create the extension I get the following error: postgres=# CREATE EXTENSION plpython3u; ERROR: could not open extension control file "/usr/local/share/postgresql/extension/plpython3u.control": No such

Running system command in Postgres and use return value in Insert

早过忘川 提交于 2020-04-11 19:44:29
问题 I have a linux command that i want to run in following function: CREATE FUNCTION tarifador_func2() RETURNS TRIGGER LANGUAGE plsh AS $$ #!/bin/sh SET userid[] = // here i want to run linux command and use that return value to insert into below table for loop with i index INSERT INTO public.act_id_priv_mapping(id_, priv_id_, user_id_, group_id_) VALUES (auuid,new.priv_id_,userid[i],new.group_id_); $$; I have following values return by command with new line: ankit ankit1 Can anyone help me to

PostgreSQL unable to create plpythonu extension

只谈情不闲聊 提交于 2020-01-24 03:02:07
问题 I'm trying to write a function in PostgreSQL on Windows with a Python script in the body and i'm running into an error message when trying to create the plpythonu extension. The command I'm running is: CREATE EXTENSION plpythonu; Which produces the following error message: ERROR: could not access file "$libdir/plpython2": No such file or directory SQL state: 58P01 I also tried running: CREATE EXTENSION plpython3u; which results in this error: ERROR: could not load library "C:/Program Files

How to aggregate matching pairs into “connected components” in Python

十年热恋 提交于 2020-01-20 16:51:27
问题 Real-world problem: I have data on directors across many firms, but sometimes "John Smith, director of XYZ" and "John Smith, director of ABC" are the same person, sometimes they're not. Also "John J. Smith, director of XYZ" and "John Smith, director of ABC" might be the same person, or might not be. Often examination of additional information (e.g., comparison of biographical data on "John Smith, director of XYZ" and "John Smith, director of ABC") makes it possible to resolve whether two

How to aggregate matching pairs into “connected components” in Python

不想你离开。 提交于 2020-01-20 16:45:34
问题 Real-world problem: I have data on directors across many firms, but sometimes "John Smith, director of XYZ" and "John Smith, director of ABC" are the same person, sometimes they're not. Also "John J. Smith, director of XYZ" and "John Smith, director of ABC" might be the same person, or might not be. Often examination of additional information (e.g., comparison of biographical data on "John Smith, director of XYZ" and "John Smith, director of ABC") makes it possible to resolve whether two

Installing plpythonu on Windows

点点圈 提交于 2020-01-04 02:38:10
问题 I'm trying to install plpython on a postgres server on a Windows machine. When I issue the command CREATE EXTENSION plpython3u; in postgres, I get the following error, which I'm trying to find the source of. ERROR: could not load library "C:/Program Files/PostgreSQL/9.3/lib/plpython3.dll": The specified module could not be found. This file exists, which I presume means that Windows can't find one of the files it depends on. When I open the plpython3.dll with Dependency Walker, it tells me it

Postgres database crash when installing plpython

不问归期 提交于 2020-01-02 05:46:46
问题 I'm trying to install plpython in my Postgres 9.1 but it crashes the server: postgres@dataserver1:~> /opt/postgres/9.1/bin/psql -d mydb psql.bin (9.1.4) Type "help" for help. mydb=# create language 'plpythonu'; The connection to the server was lost. Attempting reset: Failed. I have python 2.6.8 installed and the handler is correcty declared in the system: select tmplname, tmplhandler, tmpllibrary from pg_pltemplate where tmplname like 'plpython%' "plpythonu" | "plpython_call_handler" | "

array function returning empty

孤者浪人 提交于 2019-12-24 07:35:17
问题 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 char(1) = '"' -- field quotation ) RETURNS text[] AS $f$ import csv row = csv.reader( [line], quotechar=quote_char, delimiter=delim_char, skipinitialspace=True, escapechar='\\' ) next(row) $f$ IMMUTABLE language PLpythonU; SELECT split_csvline('a,b'); -- empty! EDIT Notes It