相关疑难解决方法(0)

如何允许在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;  
Run Code Online (Sandbox Code Playgroud)

但是,它会出现以下错误:

********** 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.
Run Code Online (Sandbox Code Playgroud)

即使我改变了许可 ekodev@partner:~/Documents$ sudo chmod a+rwX /home/ekodev/ …

postgresql ubuntu

18
推荐指数
5
解决办法
4万
查看次数

在不同的服务器上使用Rails的postgresql COPY命令的问题

我有一个已成功运行数月的rails应用程序.在一些地方,我通过ActiveRecord :: Base.connection.execute(sql_code)直接调用数据库

由于最近需要扩展,我刚刚添加了第二台服务器进行数据处理.我想运行相同的应用程序,但通过网络连接到其他数据库服务器.这是唯一的区别.应用程序的所有其他区域都可以工作 - 它可以连接到远程数据库.

它破坏的地方,是我有rails的地方发出psql COPY命令来导入csv文件.

   result = ActiveRecord::Base.connection.execute( @PGSQL_COPY_COMMAND )     # perform the copy command
Run Code Online (Sandbox Code Playgroud)

这失败并说无法找到csv文件.我已经验证它在那里,并且对于运行rails app和postgres用户的用户都是可读的.

我错过了什么吗?

postgresql ruby-on-rails

8
推荐指数
2
解决办法
6688
查看次数

标签 统计

postgresql ×2

ruby-on-rails ×1

ubuntu ×1