函数plpython3u中的文件访问问题

时间:2018-11-27 19:14:26

标签: python database postgresql plpython

这是我的代码:

CREATE OR REPLACE FUNCTION trigger_function() RETURNS TRIGGER AS $$
d_pgsql = 'kupa kupa kupa'
file = open(r'C:\Users\Bartek\Desktop\testowanie\test.txt', 'a')
file.writelines(d_pgsql)
file.close()
$$ LANGUAGE 'plpython3u';

CREATE TRIGGER my_trigger
  AFTER INSERT
  ON test
  FOR EACH ROW
  EXECUTE PROCEDURE trigger_function();

执行inserta时,会出现以下错误:

SQL Error [38000]: BŁĄD: PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Bartek\\Desktop\\testowanie\\test.txt'

为什么以及如何解决?

0 个答案:

没有答案