Thread

  1. copying table to a file

    Tyler Robert Wood <twood@csd.uwm.edu> — 2000-06-16T19:57:13Z

    Hi,
    I am attempting to copy the contents of a table to a file, like this:
    
    foodserver=> COPY company TO '/home/peter/copytest.out';
    
    
    But I keep getting this error:
    
    ERROR:  COPY command, running in backend with effective uid 100, could not
    open file '/home/peter/copytest.out' for writing.  Errno = Permission
    denied (13).
    
    Does anybody know how I can fix this so I have permission to open files?
    
    Thanks,
    
    Tyler Wood
    twood@uwm.edu
    
    
    
  2. Re: copying table to a file

    Martijn van Oosterhout <kleptog@cupid.suninternet.com> — 2000-06-17T14:40:11Z

    Tyler Robert Wood wrote:
    > 
    > Hi,
    > I am attempting to copy the contents of a table to a file, like this:
    > 
    > foodserver=> COPY company TO '/home/peter/copytest.out';
    > 
    > But I keep getting this error:
    > 
    > ERROR:  COPY command, running in backend with effective uid 100, could not
    > open file '/home/peter/copytest.out' for writing.  Errno = Permission
    > denied (13).
    
    Use \copy in psql or do it yourself from within
    a program. COPY tells the database server to
    copy the data, which may not even be on the
    same machine...
    
    > Does anybody know how I can fix this so I have permission to open files?
    
    It's using the backend permissions, which probably can't
    write anywhere. Use \copy and be happy...
    -- 
    Martijn van Oosterhout <kleptog@cupid.suninternet.com>
    http://cupid.suninternet.com/~kleptog/
    
    
  3. Re: copying table to a file

    Trurl McByte <trurl@realtor3d.odessa.ua> — 2000-06-17T15:41:36Z

    On Fri, 16 Jun 2000 (Yesterday), Tyler Robert Wood wrote:
    
      TRW> 
      TRW> Hi,
      TRW> I am attempting to copy the contents of a table to a file, like this:
      TRW> 
      TRW> foodserver=> COPY company TO '/home/peter/copytest.out';
      TRW> 
      TRW> 
      TRW> But I keep getting this error:
      TRW> 
      TRW> ERROR:  COPY command, running in backend with effective uid 100, could not
      TRW> open file '/home/peter/copytest.out' for writing.  Errno = Permission
      TRW> denied (13).
      TRW> 
      TRW> Does anybody know how I can fix this so I have permission to open files?
    Make allow access to '/home/peter' for user #100
    Or better make in your home something like:
    
     $ cd /home/peter
     $ mkdir sql
     $ chmod 777 sql
    
    and after this make
    
     foodserver=> COPY company TO '/home/peter/sql/copytest.out';
    
    Attn: You can have "superuser" permission for work with files from sql!
    
    
    Method #2: 
    
     $ psql foodserver -c "COPY company TO stdout" -o /home/peter/copytest.out
    
    This method don't need "superuser" permission...
    
    
    -- 
          Trurl McByte, Capt. of StasisCruiser "Prince"
    |InterNIC: AR3200                   RIPE: AR1627-RIPE|
    |--98 C3 78 8E 90 E3 01 35  87 1F 3F EF FD 6D 84 B3--|