I have a Cloud SQL instance running PostgreSQL, and a .csv file on my local computer.
I created a user and a database. I logged in as that user, with that database and created a table that matches my .csv file.
I have a .csv file, and an import.sql file with the following:
COPY <my-table-name>
FROM 'C:\<path-to>\data.csv'
WITH (FORMAT csv);
When I run the psql command:
psql -f import.sql <connection string>
I get back:
psql:./import.sql:3: ERROR: must be superuser to COPY to or from a file
HINT: Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.
I tried making my user a 'superuser' by doing it as the postgres
user, but I get this:
psql:./add-superuser.sql:1: ERROR: must be superuser to alter superusers
Showing all users, shows:
postgres-> \du
cloudsqladmin | Superuser, Create role, Create DB, Replication, Bypass RLS
cloudsqlagent | Create role, Create DB | {cloudsqlsuperuser}
cloudsqlreplica | Replication | {}
cloudsqlsuperuser | Create role, Create DB | {}
<my-user> | Create role, Create DB | {cloudsqlsuperuser}
postgres | Create role, Create DB | {cloudsqlsuperuser}
postgres
is a cloudsqlsuperuser, but not a 'Superuser'. How to I import this .csv file?
I don't know how to login/get access as the user cloudsqladmin
, or to grant a role to allow importing a file. I desperately need help quickly.
Google's documentation in this one area of Cloud Sql, with Postgres is horrible. It sends me all over, and is very confusing.