Best way to import a plpythonu module - Mailing list pgsql-general

From Chris McDonald
Subject Best way to import a plpythonu module
Date
Msg-id 826422c7-7aa6-497c-9b6f-5f11864a2bca@b31g2000prb.googlegroups.com
Whole thread Raw
List pgsql-general
I am using plpythonu on linux version postgresql-plpython-8.2.9-1.fc7.

Consider a python class called Wibble which is written into a python
module wibble.py.
I wish to use Wibble from within a plpythonu procedure.

If I simply do:

from wibble import Wibble

then I am told the object was not found, (presumably because postgres
does not know where the module is).

So as far as I can see, my available options to use class Wibble are:

1. Add code to modify the search path before my import statement. This
allows me to find wibble for the duration of my session I think

2. Set environment variable PYTHONPATH in user postgres .bash_profile
to add a directory where I can put my module - then restart
postgresql. This does not seem particularly safe to me though. I also
wonder if I would need to restart postgresql to reload a modified
module or whether the module is freshly read whenever a new reference
is made it it?

Is there a "best practise" approach here?


pgsql-general by date:

Previous
From: "Michael Thorsen"
Date:
Subject: SQL query
Next
From: Michal Szymanski
Date:
Subject: Re: Using Postgres to store high volume streams of sensor readings