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!

3
  • 1
    Did you see this answer: stackoverflow.com/a/19167015/724039 ? Commented Sep 25, 2021 at 16:38
  • Where are you running psql on the server or the client? Add answer as update to your question. Commented Sep 25, 2021 at 16:39
  • Try and identify the line that caused the error. Where does the https:/ (with one slash!) come from? Commented Sep 25, 2021 at 20:25

1 Answer 1

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'
Sign up to request clarification or add additional context in comments.

2 Comments

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.
Can you please upvote my answer..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.