Обсуждение: Best way to import a plpythonu module

Поиск
Список
Период
Сортировка

Best way to import a plpythonu module

От
Chris McDonald
Дата:
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?