create or replace function pytest()
returns timestamp as $$
from datetime import datetime
plan = plpy.prepare('select $1 as my_datetime', ['timestamp'])
rv = plpy.execute(plan, (datetime.now(),))
return rv[0]['my_datetime']
$$ language plpythonu;
select pytest();
pytest
2016-07-20 13:57:59.625991
告诉
prepare
方法参数值的类型timestamp
,然后将datetime
值传递给execute
方法:Database Access from PL/Python
相关问题 更多 >
编程相关推荐