anthonydb / practical-sql

Code and Data for the First Edition of "Practical SQL" by Anthony DeBarros, published by No Starch Press (2018).
Other
662 stars 409 forks source link

Windows File/Folder Permissions for COPY #33

Open anthonydb opened 3 years ago

anthonydb commented 3 years ago

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.
acmflores97 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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!