Re: PostgreSQL COPY Statement Error On Linux

From: Osahon Oduware <osahon(dot)gis(at)gmail(dot)com>
To: Francisco Olarte <folarte(at)peoplecall(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL COPY Statement Error On Linux
Date: 2017-09-12 16:28:34
Message-ID: CAGpiUShcDUh=fxgHt+zz7p5Nx7Xqt=ZZ7oZzcj7RAMRP5j2rbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Francisco,

Thanks for your response. I would try this out and give you feedback.

On Tue, Sep 12, 2017 at 12:00 PM, Francisco Olarte <folarte(at)peoplecall(dot)com>
wrote:

> On Tue, Sep 12, 2017 at 12:30 PM, Osahon Oduware <osahon(dot)gis(at)gmail(dot)com>
> wrote:
> > I am trying to utilize the "COPY" statement below to copy a .CSV file to
> a
> > table in a PostgreSQL database.:
> > COPY <schema>.<table_name>(<table_columns>) FROM
> > '\\shared\network\path\to\csv\test.csv' DELIMITER ',' CSV HEADER;
> >
> > This works with a PostgreSQL database installed in a WINDOWS environment
> > (Windows 7), but fails with the following error with a similar PostgreSQL
> > database in a Linux environment (Centos 7):
> > org.postgresql.util.PSQLException: ERROR: could not open file
> > "\\shared\network\path\to\csv\test.csv" for reading: No such file or
> > directory
> >
> > I have granted READ access to EVERYONE on the CSV folder on the network
> path
> > as depicted in the attached image.
> > Could someone point me to the reason for the failure in Linux?
>
> You are invoking server side copy. This means the SERVER neads to be
> able to access the file under the name you've given to it.
>
> The network path you have given is valid on windows machines ( UNC
> path? It's been a decade an a half since Iast used windows ), but not
> on linux. Typically on linux you mount the shared folder /some/where
> and type the path as /some/where/path/to/csv/test.csv.
>
> You may be needing a CLIENT copy. I do not see which client program
> you are using, it may be some fancy GUI stuff, in which case I cannot
> help you. If you are using the standard "psql" tool you can just use
> \copy. As explained in the docs this just does "copy from stdin" ( or
> to stdout ) on the client side and redirects the file you give in the
> command line ( or you can issue a [psql ... -c "copy ...from stdin"]
> in a command line and feed the file via shell redirections, but, IIRC,
> windows shells are terrible at quoting arguments and redirecting i/o,
> so it may be better to avoid it).
>
> Francisco Olarte.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2017-09-12 16:29:16 Re: contrecord is requested
Previous Message Osahon Oduware 2017-09-12 16:27:35 Re: PostgreSQL COPY Statement Error On Linux