Permission denied to COPY from a file in postgres

I am trying to import data from a local file into the postgres remote database using the copy keyword in query. It shows the following error:
“Only roles with privileges of the “pg_read_server_files” role may COPY from a file.permission denied to COPY from a file”

Can I make my user a SUPERUSER? Why cant I have access to superuser in postgres ?

As a managed service there are certain permissions that aren’t granted.

But also, you can’t upload files directly to our PG so using COPY isn’t the right command here.

@John_B

Thank you for your reply. I am trying to import data from a .csv file to your PG table. If COPY is not the right way, can you guide me how to do this ?

Ah, \copy is what you want to be using here, this doesn’t require superuser - as an example Import Data from CSV into Postgres | Hasura GraphQL Docs should work

Hi,
I am running the query from a node app. for eg:
db.query(“COPY test_table FROM ‘D:\test\test.csv’ DELIMITER ‘,’ CSV HEADER;”)

I believe “\copy” is a psql shell command and cannot be run from inside node. Or is there some way to do this ?

ah ok, that’s useful to know.

Correct \copy would be used via psql which was I assuming what you were doing.

The Node app isn’t going to have access to your d:\ drive so that’s not going to work. Our native instances all have psql so that is an option whether invoking psql programmatically or using it via the shell tab directly. But probably the simplest option would be to read the CSV file in Node and then insert it into the DB