-- yum install postgresql96-contrib
-- CREATE EXTENSION file_fdw;
-- CREATE SERVER test_file_fdw FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE api.t (
id serial,
name text
)
SERVER test_file_fdw
OPTIONS ( filename '/home/q/test/file_fdw.test', format 'csv' );
GRANT SELECT ON TABLE api.t TO q;
GRANT SELECT ON TABLE api.t TO web_anon;
\q
CREATE FOREIGN TABLE t (
id serial,
name text
)
SERVER test_file_fdw
OPTIONS ( filename '/home/q/test/file_fdw.test', format 'csv' );
GRANT SELECT ON TABLE t TO q;
-- create extension plpythonu; optional???
-- create language plpythonu;
drop FUNCTION pymax (a integer, b integer);
CREATE FUNCTION pymax (a integer, b integer)
RETURNS setof text
AS $$
import sys
import os
import datetime
import time
#time.sleep(a)
t_old = getattr(os, "t", "null")
os.t = str(datetime.datetime.now())
with open("python-test","a") as f:
f.write(str(datetime.datetime.now()))
return [os.getcwd(), sys.version, t_old, os.t] + sys.path
$$ LANGUAGE plpythonu;