5

I am writing some common functions to use in pl/Python in PostgreSQL.

The python modules are loaded into PL/Python functions by:

from sys import path
path.append('/PythonLibrary/PostgreSQL')
from Module import funcA, funcB, etc

This works OK until you change the module source code. The server has the code cached, or in a compiled state, but it fails to detect changes and reload.

How is Postgres handling this, and how can I get changes detected and handled appropriately.

Thanks.

2
  • try restarting the server (postgresql) Commented Oct 13, 2017 at 22:25
  • I was hoping to avoid doing that. Commented Oct 13, 2017 at 22:29

1 Answer 1

2

Use the function reload(module), example (Python 3.3):

from imp import reload
import my_module
my_module = reload(my_module)
from my_module import my_function

In Python 2 reload() is a built-in function, in Python 3 it was moved to the imp module, in 3.4 and later it is in importlib.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.