繁体   English   中英

PostgreSQL错误-psql:fe_sendauth:未提供密码

[英]PostgreSQL Error - psql: fe_sendauth: no password supplied

我在AWS RDS中具有数据库名称为some_files PostgreSQL设置。
DB的用户名是mobileuser 它已被赋予超级用户权限

我想每天在名为data_table表中复制csv文件。 因此,我编写了一个python脚本(使用psycopg2),该脚本将连接到该数据库并进行复制。 我尝试使用COPY命令。 但是收到一个错误

COPY mobile user.data_table FROM 'csv_location';

它给我一个错误,我需要成为超级用户才能执行此操作。 根据https://forums.aws.amazon.com/thread.jspa?threadID=141798

RDS is a managed service and in order to prevent situations that compromise that service, localhost access is not permitted. The Postgres "COPY" command causes the server itself to read/write files -- potentially directly on the Postgres host. Therefore it is restricted. An alternative is to use the client based, psql instruction "\\copy". Documentation for that command can be found in the Postgres online manual.

所以我尝试使用psql使用\\copy命令

terminal_command = "psql -h rds_hostname -U mobileuser -w -d some_files -c \copy "+schema_name+"."+table_name+" FROM 'csv_location' DELIMITER '|' CSV HEADER"
subprocess.call(terminal_command,shell=True)

我将.pgpass文件添加到我的主目录*:*:*:*:my_password ,权限为600

尽管如此,它仍然给我错误psql: fe_sendauth: no password supplied我正在使用root用户运行python脚本

当你...

root用户身份运行python脚本

(为什么?). .pgpass文件必须位于root的主目录中, 而不是用户帐户的主目录中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM