Im trying to achieve a massive data insertion (about 50.000) from a CSV file uploaded into Supabase Storage from the frontend, and process data inside a Serveless Supabase Edge Function, trying to make the insertion using the COPY
command into PostgreSQL (Supabase) directly from the CSV file.
The sequence I’m trying is:
-
User uploads a large CSV file to Supabase Storage (about 4MB, like 50.000 rows)
-
A “job” row is inserted in “jobs” table in database, with the csv file location in Storage
-
A Supabase Edge function is triggered when the job is inserted
This function gets the CSV file location and creates a SignedUrl
for downloading the CSV.
I create a PostgreSQL client using the “postgres” library for Deno (import { Client } from "https://deno.land/x/postgres/mod.ts"
) and instantiate with the Admin
authenticated user.
I use the COPY
command with signedUrl
to try to make the insertion:
COPY reports FROM '${signedUrl}' WITH (FORMAT csv, HEADER true)
I then got the error:
must be superuser or have privileges of the pg_read_server_files role to COPY from a file
When I try to grant that privileges to my user in Supabase SQL Editor:
GRANT pg_read_server_files TO my_user
I got the error:
ERROR: 42501: "pg_read_server_files" role memberships are reserved, only superusers can grant them
So… Im supposed to be the superuser or what? I’m the supabase project creator, it’s my own account.. so what does this all means ? And how can I achieve what I want, if there’s some other way.. please help!!
Leonardo Dimieri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.