DEV Community

Discussion on: Loading JSON into Postgres

 
kiwicopple profile image
Copple

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 postgres

You use the connection details for the Supabase database

PGPASSWORD=[your password] psql -h XXX.supabase.co -p 5432 postgres -U postgres 

You can find the connection details in the "settings" page of your project in Supabase

Thread Thread
 
affluentbilbyclassifieds profile image
affluent-bilby-classifieds

That's fantastic! Thanks Copple. I will do that tomorrow morning.

Thread Thread
 
affluentbilbyclassifieds profile image
affluent-bilby-classifieds

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

Thread Thread
 
affluentbilbyclassifieds profile image
affluent-bilby-classifieds • Edited

Looks like it's worked!

Thank you!

Thread Thread
 
kiwicopple profile image
Copple

Woohoo! I'm impressed you pursued this all the way to the end. If you need help with anything else, feel free to reach my cofounder and I on alpha@supabase.io. Would love to hear more about what you're building

Thread Thread
 
affluentbilbyclassifieds profile image
affluent-bilby-classifieds • Edited

The next thing I need to find out is how to use it as a datasource (restful API I think it's called) for react-admin. Is there a similar page to the "connection details" that gives me the path information I need to enter into my react-admin code related to data provider (currently using ra-data-simple-rest) configuration?

Admin dataProvider={simpleRestProvider('http://path.to.my.api/')

edit: I just saw your response.

should I remove my next question and e-mail instead?

Thread Thread
 
kiwicopple profile image
Copple

I've never used React Admin, so I don't know exactly how it would work, but I imagine you can go to the "Docs" section in your dashboard and use the "Bash" commands to "cURL" the data 😂. What a mouthful

Alternatively, we have a table view, which is getting better every week. (go to the "Zap" icon, then toggle at the top between Table/SQL). We have some huge improvements coming this week, and eventually you won't even need React Admin - we are building it for you :). If you've ever used Airtable, this is how our Table View will function

Thread Thread
 
affluentbilbyclassifieds profile image
affluent-bilby-classifieds

Thanks Copple.

If I can "cURL" I can probably use axios or fetch for CRUD. I will check out the docs and link this thread to our dev.
We do intend to use React-Admin and it will become a dashboard for the business.