Bulk row insertin Supabase

I want to upload bulk rows in a Supabase table using a CSV file from Weweb (using file upload component). That CSV file would contain all the columns exactly the same order the way the columns are in the Supabase table. Will somebody please help me how to do this. My entire project is on hold just for this feature. Kindly help.

Hi @Sourav :wave:

If I understand correctly:

  1. you would want the user to be able to upload a CSV
  2. you don’t need to store that CSV file in Supabase
  3. but you want to update a Supabase table with the rows from that CSV

Is that correct?

In addition, you mention “using a CSV file from Weweb”. Does this mean that you want to store the CSV file in WeWeb’s CDN or is that not important as long as the rows are updated in Supabase?

Hi Joyce, thanks for replying. Thankfully i managed to resolve the issue. I wanted to upload bulk rows (insert or upsert), just the way we do for single insert in Supabase. I managed to do it with a piece of JS code and Supabase bulk insert option (newly introduced feature). Thanks again for your support. If you want i can share the worflow demo of it with video snapshot in this thread.

1 Like

Awesome! Glad you found a solution.

Not sure if you saw but you can do bulk inserts with our no-code workflow action:

Hi @Sourav, how did you do this ? Would love to see how you managed it

Hi @Corner,
Enclosed is the piece of code for your ref. you just need to capture the raw rows of data using CSV file
and upload component ,post that replace your variable value with the existing one in the code. Hope it will work. Please make sure all the columns in the CSV are in the same order as the DB table.


Please let me know for any further query.

2 Likes

Thanks a lot @Sourav, i’m gonna check on this and let you know :slight_smile:

Is this technique working with a csv file ? Or should I first put a js script to parse the doc, then make an object of the parsed data and then multiple insert ? Thanks

Hi @Joyce,
“Or should I first put a js script to parse the doc, then make an object of the parsed data and then multiple insert”

Yes what you have described, this is the exact way this workflow works, but the piece of JS code will make the uploaded object exactly the way SB receive multiple rows to insert or upsert. To make it work we just need to declare the variable in this JS code post capturing the CSV file within upload element.

1 Like

Thanks @Sourav for your reply. I will try to do this on my own, but as it seems a bit technical I may need some help further haha

@Sourav @Joyce little question. My client gave me this xls document :

It’s like a summary of customers (“Groupe X”) who have subsidiaries (“Alliance Colmar” for example) and sales with suppliers (“Initial” for example).

Do you think it’s possible to populate a Supabase table with it ? Problem is, it’s not like one table with different columns, but rather a lot of different sheet within one table …

I don’t think it is possible, as Supabase doesn’t support this way. Instead you can join the columns horizontally, before that you need split the sheet into three and use transpose function. As this should be
done programmatical, i am suggesting you to have a look on this. PostgreSQL: Documentation

Hello, this is doable, but would require some JavaScript (for data manipulation), if you’d need it, let me know and we can arrange something. Otherwise I’d suggest simplifying your file and it should work.

Hello guys, thanks for the answer. I managed to make my client change his work document as this is not even safe to work only on sheets (they didn’t have any db so far). So basically, the app I’m working on will become the place to register any data ! No more need to import data as they will insert it directly :slight_smile:

1 Like

Beautiful! Congrats on convincing your client to tweak their work habits. I’m sure it will save them (and you :sweat_smile:) loads of time and headaches in the long run!