actually we would to something another way around ;) snake inside the elephant, not the other way around like in the little prince story.
good intro can be this talk available on youtube:
followed by it's slides: https://wulczer.org/pywaw-summit.pdf
prelude - what do you need to setup in your postgres?
if you play with plpython3u on fresh postgres instance you will probably need install/setup the following:
apt-get update
apt-get install postgresql-plpython3-11
- be careful to install good version for your postgres version:
inside psql:
CREATE EXTENSION plpython3u;
example fun
create function histogram(a float[], bins int = 10)
returns int[]
as $$
import numpy
return numpy.histogram(a, bins)[0]
$$ language plpython3u;
- you may need install on postgres machine additional python libraries (e.g
numpy
for above), first install pip:apt-get install python3-pip
Important things to remember:
- keep you functions in separated module with option to mock plpython magic, so these are GOOD tested
Top comments (0)