我在将 CSV 文件从网络共享驱动器复制到 postgreSQL 时遇到问题,目前的解决方法是先将文件复制到本地驱动器,但这是链中的另一个过程,它变得过于混乱。
如果我运行以下命令
COPY test_schema.test FROM 'X:\_Postgres DBs\Testing\test_file.csv'
CSV HEADER;
Run Code Online (Sandbox Code Playgroud)
我得到:
ERROR: could not open file "X:\_Postgres DBs\Testing\test_file.csv"
for reading: No such file or directory
Run Code Online (Sandbox Code Playgroud)
好的,所以 postgreSQL Server 不理解 Windows 映射驱动器,很好,但是如果我运行:
COPY test_schema.test FROM '\\ws7.domain.com\share-name\_Postgres
DBs\Testing\test_file2.csv' CSV HEADER;
Run Code Online (Sandbox Code Playgroud)
我得到:
ERROR: could not open file "\\ws7.domain.com\share-name\_Postgres
DBs\Testing\test_file2.csv" for reading: Permission denied
Run Code Online (Sandbox Code Playgroud)
文件 test_file2.csv 可以在同一台服务器上本地打开,例如记事本/记事本++/写字板,因此看起来没有任何文件属性,例如“正在使用的文件”
任何人有任何提示如何将 COPY 与共享网络驱动器一起使用?(我们的数据库 UI 是用 Delphi 编码的,所以我正在寻找处理 postgresql 脚本的方法,我可以从 Delphi 调用,否则我将不得不编写一些繁琐的 Delphi Firedac 批处理方法。)