Today I had to load some JSON data into Postgres.
Postgres' COPY command it expects one JSON object per line rather than a full array.
For examp...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks for this Copple. I have signed up my project to the Supabase.io alpha program. I followed the instructions here. Can I please have the additional instructions to import the file into the "CREATE TABLE" page in Supabase? Thank you.
Hey! This is actually specific to Postgres, not the Supabase interface. We are building easy ways to load data in Supabase, but they aren't finished yet.
You can use the method i describe in this article to load directly into the Postgres database we give you - you will need to connect to it directly using psql. Do you have psql on your computer?
Hi Copple.
Yes, I am running postgres (psql 9.6.18) in a docker container. I have successfully followed your instructions. It was after that I read about supabase and said Eureka!
I was going to try importing it today. I exported it first.
I used: "pg_dump -d menudb -U fruty -t menu > file.sql" but I haven't tried importing that into supabase as yet. I can put the contents in a codepen if you like.
I am very interested in directly importing it to the supabase Postgres database if you can advise how I should proceed.
Thank you
You can import it exactly as you do it on the local machine! The key difference is that you need to change the connection parameters. So instead of the local host:
psql -h localhost -p 5432 postgres -U postgresYou use the connection details for the Supabase database
You can find the connection details in the "settings" page of your project in Supabase
That's fantastic! Thanks Copple. I will do that tomorrow morning.
psql -h XXXX.supabase.co -p 5432 postgres -U postgres -c "CREATE TABLE menudb (data jsonb);"
Password for user postgres:
CREATE TABLE
root@45279c35af82:/init/json# cat output.json | psql -h XXXX.supabase.co -p 5432 postgres -U postgres -c "COPY menudb (data) FROM STDIN;"
Password for user postgres:
COPY 34