即使拥有755权限,Postgres也无法读取CSV

时间:2017-01-03 01:04:30

标签: postgresql file-permissions

我有一个脚本,用于设置一个测试数据库(在Web应用程序中),该数据库使用从Postgres驱动程序而不是psql运行的COPY命令填充数据库。

我读到Postgres将以postgres用户身份运行该命令。

但是我收到了42501这样的错误:

import os
import time
import multiprocessing

# A dummy function representing some fixed functionality.
def do_something(x):
    print('I got a thing:', x)

# A main function, run by our workers. (Remove role arg for working example)
def worker_main(queue, roles):
    role = roles.get()
    print('The worker at', os.getpid(), 'has role', role, ' and is initialized.')

    # Use role in some way. (Comment out for working example)
    do_something(role)

    while True:
        # Block until something is in the queue.
        item = queue.get(True)
        print(item)
        time.sleep(0.5)

if __name__ == '__main__':

    # Define some roles for our workers.
    roles = [1, 2, 3]

    # Instantiate a Queue for communication.
    the_queue = multiprocessing.Queue()
    roles_queue = multiprocessing.Queue()
    for role in roles:
        roles_queue.put(role)


    # Build a Pool of workers, each running worker_main.
    # PROBLEM: Next line breaks - how do I pass one element of roles to each worker?
    the_pool = multiprocessing.Pool(3, worker_main, (the_queue, roles_queue))

    # Iterate, sending data via the Queue.
    [the_queue.put('Insert useful message here') for _ in range(5)]

    worker_pool.close()
    worker_pool.join()
    time.sleep(10)

所以我尝试将postgres添加到拥有所有文件夹的组中,直到该csv(root除外)。以下是权限和组:

adb shell su 0 setenforce 0

但我仍然得到同样的错误。我认为通过向用户组添加postgres,它将能够读取如上所示的文件。我是否需要将其添加到根组?或者让用户拥有/ folder?

0 个答案:

没有答案
相关问题