无法在使用系统调用运行Python脚本的PostgreSQL中执行C函数
我有以下资料:无法在使用系统调用运行Python脚本的PostgreSQL中执行C函数,python,c,postgresql,system-calls,Python,C,Postgresql,System Calls,我有以下资料: /* execute_py.c */ #include <stdio.h> #include <stdlib.h> #include "postgres.h" #include "fmgr.h" #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC; #endif int call_py() { printf("Executing your Python script..."); return s
/* execute_py.c */
#include <stdio.h>
#include <stdlib.h>
#include "postgres.h"
#include "fmgr.h"
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
int
call_py()
{
printf("Executing your Python script...");
return system("python36 absolute/path/to/example.py");
}
我将c脚本编译成execute\u py.o
和execute\u py.so
然后在PostgreSQL server中创建了一个函数:
CREATE OR REPLACE FUNCTION call_py() RETURNS integer
AS 'absolute/path/to/execute_py', 'call_py'
LANGUAGE C STRICT;
并尝试像这样运行函数:
SELECT call_py();
函数返回0。但是当我检查文件夹时,没有生成test.txt
我是C的新手,不知道发生了什么。寻求帮助
谢谢你 对不起,我太笨了,忘了将执行权限添加到
example.py
SELECT call_py();