7

I am using Windows 10

I have a PostgreSQL file when I run inside the PSQL CMD

\i FILENAMEPATH

postgres=# \i C:\Users\Asus\Desktop\Projects\Movies\solution.sql
C:: Permission denied

I get that Permission Denied

C:: Permission denied

Is there a way around this? Or how can I gain permission?

Mohamed
  • 425
  • 4
  • 14
  • 6
    Try forward slashes `\i c:/Users/Asus/Desktop/Projects/Movies/solution.sql` –  Jul 27 '21 at 14:07
  • 1
    I encountered the same problem, but after spending an hour searching the web, I stumbled upon your comment and your solution worked perfectly for me. Thank you so much for sharing! @a_horse_with_no_name – vetheve Jan 10 '23 at 09:56

2 Answers2

12

As a_horse_with_no_name pointed out, using forward slashes instead of backslashes in the address solves the problem.

This is because windows unlike most OSs, resolves paths with forward slashes.

Sadra M.
  • 1,304
  • 1
  • 17
  • 28
0

What solved this issue for me is opening a PowerShell in the folder location of the sql file (in folder: shift + right-click -> open PowerShell here), to avoid having to provide a file path, and then running '\i filename.sql'

Sufyx
  • 1
  • 1