How to load data from external db into bubble db

So I want to connect my bubble db to an external db (Planetscale) but I am not sure how to do it. Basically what I like, is to update the bubble db to match the external db every minute. Currently I am trying to do it using the SQL db connecter plugin, but I can’t seem to figure out the workflows for updating every entry in the bubble db. Any help is much appreciated : D

Trying to have two identical synched databases is not a good idea. It would be crazy expensive, inefficient and very prone to error, and there is no benefit to it.
There should only be one database. Either use the Bubble database, or the external database. You could keep some tables on the bubble database and some other on the external db, thats completely fine, however you shouldn’t have duplicate tables in different dbs.

Having said that, If you want to cherry pick some data for processing from a db that you dont have control ovee then that would be ok, but a few minutes seems a bit too frequent and it will rack up your costs substantially.

What are you trying to do exactly with this data? Can you give more details?

1 Like

As @nico.dicagno said, it could be a nightmare keeping two full databases synched.
But if what you need to synch are just portions of the database, a good solution would be using Webhooks to do it, in this way you wouldn’t overload your server every minute without a need and also would guarantee that these data points will always be updated immediately.
Where does the data action happens?
a) On you Bubble app (and it sends the data update to Planet Scale)
b) On an external app using Planet Scale DB that send to you Bubble app the data update?
This data flow will determine where you should configure the Webhook endpoint and where you must create the action of sending a POST request to your webhook URL

1 Like

Okay, I see the issues. What I am trying to do here is that I have a db that contains information that I need to not only display but also be able to change in the Bubble UI. So I need to load the information on a lot of entries, like 50 at a time, so that I can display an overview of each. Then you can click into each and change the information on the specific entry. What would be the best way to do this?

GET and display data from your external database by API call, and make API calls to an endpoint that is able to modify your database.

Okay, so you are suggesting I use my backend to handle the communication with the db?

You can’t natively edit another database in Bubble but the SQL Connector plugin might help (I’ve never used it), or you can create some custom serverless functions to do it…

Okay, So I add the functionality to my replit backend, and make a flask app with and endpoint that is, get next 50 entries, that returns the next 50 entries, and then I load that directly into the bubble UI?

And then make it update every 60s

Would something like this work?


So I still need help. I am trying to load data form the external db to display it in the UI. My current way is to load the data into the bubble db when the user refresh, this is done by deleting the entire bubble db, and then loading in the data from the external db, given by an api endpoint. This is terrible.

Please any ideas are much appreciated. I tried to load the data from the external db direclty to the ui but I couldn’t get it to work, please help.

I got it to work, the issue was that I was using the API as data, then for some reason, it didn’t update, but now I am using the API as an action and then setting the state after that, and now everything works.