Best way to import a plpythonu module

Поиск
Список
Период
Сортировка
От Chris McDonald
Тема Best way to import a plpythonu module
Дата
Msg-id 826422c7-7aa6-497c-9b6f-5f11864a2bca@b31g2000prb.googlegroups.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: "Michael Thorsen"
Дата:
Сообщение: SQL query
Следующее
От: Michal Szymanski
Дата:
Сообщение: Re: Using Postgres to store high volume streams of sensor readings