0

Hi Im learning how to use postgresql's COPY command to import data in from a csv file on my local drive onto the postgresql db of my rails app.

The first step is how do I find the location of postgresql on my local drive?

Wouldn't I need it to call the COPY command?

I have pg3admin which I can see as a gui, it has all my databases. but where would I be calling the copy command from?

thanks

2 Answers 2

2

To COPY into a table FROM a file, the file must be accessible to the OS user running the PostgreSQL server, or (more commonly) to the OS user running your client. In the latter case, you COPY tablename FROM STDIN, and your client application feeds the file to the server. To do this in psql you use \copy.

Sign up to request clarification or add additional context in comments.

Comments

0

Most of postgres lives (assuming you're using a *nix OS) in /var/lib/pgsql. The postgres manual has more info about where files are commonly found, and what each file does.

2 Comments

The location of those files is completely irrelevant when using COPY
@a_horse_with_no_name Not completely, no. If you give a relative path to COPY it'll look for a file within the datadir.

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.