anthonydb/practical-sql

File access denied on MacBook Air using COPY

DanielaScoppa opened this issue · 5 comments

Please include the chapter number in your issue title. For example: "Chapter 3: Listing 3-1

General

Please answer all of these as they're essential for troubleshooting.

**What's your operating system : macOS Catalina

Did you install PostgreSQL and pgAdmin according to the steps on page xxviii of the book's Introduction? If not, please describe your installation.
Yes

*Versions of PostgreSQL and pgAdmin 4 are you using? Version 5.5 (4280.88)

**Did you download the book's code examples and data from GitHub using the directions on page xxvii of the Introduction? Yes

Issue or Question

**Chapter, page and code listing number:3 page 25

Describe the issue or your question:
I cannot get permission to write to the textfile on macbook Air. I have given permission for PGadmin to acces the file

ERROR: could not open file "/Users/dasc/OneDrive - Myname/typetest.txt" for writing: Permission denied
HINT: COPY TO instructs the PostgreSQL server process to write a file. You may want a client-side facility such as psql's \copy.
SQL state: 42501

I dont understand whats is wrong

Hi, can you try using a different path? For example, try /Users/dasc/Desktop/typetest.txt for starters and let me know what happens.

I have tries to put my file on the desktop as You described above. My Macbook does still not a allow to acces the file. I have given permission to read and write to file with postgres.

This is unusual and not something I've encountered. It may be related to Catalina's permissions issues in general or your specific machine, as far as I can tell. I would suggest reading this article on how to control app permissions.

On my Mac (running Big Sur), Postgres.app has Desktop permission:

Screen Shot 2021-09-29 at 8 34 01 AM

Also, if you navigate to your Applications folder and right-click on Postgres.app, select Get Info and check the permissions section. Does it have permission for your user? Here's mine:

Screen Shot 2021-09-29 at 8 44 18 AM

If none of those help, you can check the Postgres.app's GItHub: https://github.com/PostgresApp/PostgresApp

It worked. I can now write to a file on the desktop. Thank You very much for being so helpfull :)

@DanielaScoppa Excellent. Also, I recommend you place the code/data from this repo in that same folder. You will need to import CSV files and the PostgreSQL server will need the same permission.