'Python input function inside PostgreSQL is not working
I'm a beginner in PostgreSQL, and I am using pgAdmin 4. I am trying to implement a Python function inside Postgres to get the location of a file as a text or string from keyboard, load that file later. But when I run the code, it does not give me the option to type the input, and it says "WAITING FOR THE QUERY TO COMPLETE".
Here is my try to just get the path to the file and print it:
CREATE or REPLACE LANGUAGE plpython3u;
CREATE FUNCTION getinput()
RETURNS text
AS $$
val = input("Please enter the directory path including you file:")
return val
$$ LANGUAGE plpython3u;
select getinput();
Could someone help me where I am making mistake or what the problem is?
Thanks
Solution 1:[1]
You cannot have user interaction in a database function, which is running on the database server. Prompt the user for input in client code and supply the result as function argument.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Laurenz Albe |
