Remote database with docker

I set up a managed database on digital ocean per Creating Database Connections with the Database Manager

How do I keep using wappler’s target options functioning… I want the local development target to be connected to the docker DB.
Then I want the ‘live production’ target to be connected to the managed db.
Visually showing what I want:

I tried setting it in the target settings like this, but that throws an error (ECONNREFUSED)

Very curious how others with an external database solve this…

To clarify, I just want:

@karh - hopefully this will help you: Connecting to new, prod mysql8 db - connection timeout (Workbench connects perfectly)

There has been quite a few DB Connection issues reported recently, hopefully the team will pick up on these.

If I understand correctly, you want the db named connection to work for both dev and prod target, but with different settings?
And both the targets are dockers, with their DB information being part of the target settings?

@mgaussie Thanks - I can’t find a solution in there sadly.

@sid Correct!

Since wappler is handling the environments with the target settings… It makes sense to me to keep using that. Else I would have to duplicate every single server action I suppose and set them to the remote managed DB.

These are the settings right now:
Project settings

  1. Local target:
  2. Remote target:

Database manager

  1. Edit: I realised I have to first open the table to make it green, then I can edit and fetch

Server connect (live target)

  1. db is set up with connection settings of the remote db
  2. This works: queries to db are indeed done to the remote database.

Server connect (local target)

  1. db Is set to the docker settings found in the project target settings

So I just tested it all again and think this set up works.
In my test yesterday I saw that the local target was showing data from the remote database. But that was because I had selected the production target in wappler - and then opened both localhost + and checked what the query gave me. This was the same…

To fix that I selected the local target in wappler - then opened both url’s and it’s different:

I hope this doesn’t get overwritten by the project settings… would appreciate a check by someone to see if I did it correctly! @sid :innocent: ?

This is pretty much the setup I was going to suggest.
I have a similar setup, but of local dev docker which does not have a DB, and a remote dev docker with DB, which is the DB being used in both targets.

To ensure the settings & DB manager do not cause any issues, here is what I did:

  1. Select the target docker with DB. Ensure everything works as expected.
  2. Switch to target docker without DB. Here, the DB connection in DB manager should basically fail since there are no settings in the target.
  3. At this point, delete this DB connection.
  4. Create a new DB connection with the same name as of the target with DB (usually its ‘db’), with the setting pointing to the actual remote DB.
  5. Everything should connect and work now on this target.
  6. Now when you switch targets, you can refresh schema, and manage DB via DB manager too. Since both targets point to the same DB.

I have not seen any issues with Wappler updates breaking this work-around.

@sid You’re a genius! Thanks again.

I just encountered an issue: my db changes from the local target weren’t in the remote target (because my db wasn’t called db in the remote target). This fixed it!

Celebrated too soon… the db connection in server connect now broke. My queries are returning 500 errors “ECONNREFUSED”

Seems to be fixed by saving the project settings again… fingerscrossed