1

I'm a web development student and struggling to solve this problem on my own, any help would be appreciated!

Note that I'm working in an Amazon Cloud9 instance. My problem is that when I try to import an SQL file into a PostgreSQL database using the following command:

$ psql -d my_database < file_to_import.sql

I get the following error:

https:/raw.githubusercontent.com/...[removed for privacy]: No such file or directory

I know the file exists, because I'm able to navigate to it. I've tried copying the contents of the file into a new file on my desktop and then inserting the path to that file in the place of "file_to_import.sql" but that's not working either. I get the same error.

I've also tried importing via this template:

my_database=# \i ~/some/files/file_to_import.sql

But I get the same error. What's gone wrong here?

Thanks in advance!

jarlh
  • 42,561
  • 8
  • 45
  • 63
Aga
  • 11
  • 2

1 Answers1

2

These issues can be occurred because lack of permissions for a file try one of the following commands with the proper elevated permissions. For number one, you don't need sudo but if that didn't work try the second one of them should help you

 1. psql -h hostname -d databasename -U username -f file.sql
 2. sudo -u postgres psql db_name < 'file_path'
AmilaMGunawardana
  • 1,604
  • 2
  • 13
  • 32
  • Thanks so much, but this didn't seem to work. I sort of figured out a workaround by saving the file to import directly to the directory I'm working in my environment, and then importing it into postgres from there. Hopefully that will suffice for the course. Thanks again for the help. – Aga Sep 26 '21 at 13:43
  • Can you please upvote my answer.. – AmilaMGunawardana Nov 08 '21 at 15:04