Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows File/Folder Permissions for COPY #33

Open
anthonydb opened this issue Oct 10, 2021 · 3 comments
Open

Windows File/Folder Permissions for COPY #33

anthonydb opened this issue Oct 10, 2021 · 3 comments
Assignees

Comments

@anthonydb
Copy link
Owner

anthonydb commented Oct 10, 2021

If you're a Windows 10 user, you may need to set permissions for the folder holding the code and data for the book. If you don't, you may see an error similar to this:

ERROR: could not open file "C:\YourDirectory\us_counties_2010.csv" for reading: Permission denied
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
SQL state: 42501

To correct this, follow the directions in the note on page xxvii of the Introduction (Practical SQL 1st edition), in the section "Using the Book's Code Examples":

After downloading data, Windows users might need to provide permission for the 
database to read files. To do so, right-click the folder containing the code and data, 
select Properties, and click the Security tab. Click Edit, then Add. Type the name 
Everyone into the object names box and click OK. Highlight Everyone in the user 
list, select all boxes under Allow, and then click Apply and OK.
@anthonydb anthonydb self-assigned this Oct 10, 2021
@anthonydb anthonydb pinned this issue Oct 10, 2021
@anthonydb anthonydb changed the title Windows Files Permissions for COPY Windows File/Folder Permissions for COPY Oct 10, 2021
@acmflores97
Copy link

Hi! I did all this from A to Z and still unfortunately had the same error.
This still showed: ERROR: could not open file "C:\YourDirectory\us_counties_2010.csv" for reading: Permission denied
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
SQL state: 42501

I followed the directions in the note as well allowing permission and all etc.

Help please as I could not go on with my learning :(

Thank you!

@anthonydb
Copy link
Owner Author

@acmflores97 Hi, sorry you are having trouble. Usually, setting the folder permission settings takes care of the issue.

However, in your error I see this:

C:\YourDirectory\us_counties_2010.csv

Are you using a folder named "YourDirectory"?

@acmflores97
Copy link

oh sorry, I just copied and pasted the error on your post assuming it was the same on mine. But the error did show technically the same thing but with my own directory.

I got it figured out. I deleted and re-downloaded the github data and followed the book's instructions once more. AND on top of that, I had to do some extra googling where I had to change file ownership after already specifying the "Everyone" conditions that was stated in the book. Thank you though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants