-
-
Save liquidgenius/3648ff606ac9cfde05895d62fb83a860 to your computer and use it in GitHub Desktop.
plpython to read environment variable from PostgreSQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create extension plpythonu; | |
create type py_environ_type as (name text, value text); | |
create or replace function py_environ(name varchar DEFAULT NULL) | |
returns setof py_environ_type | |
as $$ | |
import os | |
aev = [] | |
if name is None: | |
for k, v in os.environ.items(): | |
aev.append((k, v)) | |
else: | |
v = os.getenv(name) | |
if v is not None: | |
aev.append((name,v)) | |
return aev; | |
$$ language plpythonu | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment