如何在Ubuntu中使用Postgres允许访问CSV文件的权限 [英] How to allow permission to access CSV file using postgres in Ubuntu

查看:86
本文介绍了如何在Ubuntu中使用Postgres允许访问CSV文件的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下命令:

copy (select so.name,
      so.date_order,
      sol.name,
      sol.product_Id,
      sol.product_uom_qty , 
      ai.number, 
      ai.date_invoice , 
      so.amount_total , 
      so.amount_tax 
      from sale_order so , 
      sale_order_line sol , 
      account_invoice ai 
      where so.id = sol.order_id 
      and so.name = ai.origin 
      and ai.state='open') 

to '/home/ekodev/Documents/test1.csv' delimiter ',' csv header;  

但是,它给出了以下错误:

However, it gives the following error :

********** Error **********

ERROR: must be superuser to COPY to or from a file
SQL state: 42501
Hint: Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.

即使我更改了权限 ekodev @ partner:〜/ Documents $ sudo chmod a + rwX / home / ekodev / / home / ekodev / Documents / /home/ekodev/Documents/test1.csv

它仍然

有人知道问题出在哪里吗?

Does anybody know what the problem is?

推荐答案

此解决方案使用 $ copy 为我工作。

This solution worked for me using \copy. ALTER did not as that also required admin privileges.

psql -h <host> -U <user> -d <dbname> -c "\copy <table_name> FROM '<path to csvfile/file.csv>' with (format csv,header true, delimiter ',');"

这篇关于如何在Ubuntu中使用Postgres允许访问CSV文件的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆