How to assign different db connections to Targets

https://docs.wappler.io/t/define-database-connection-settings-per-target/27577

The instructions don’t seem to be working. I expect to finish with 2 different db connections but always overwrite whatever was in the Globals/Database Connections properties.

When I change Target from Dev to Production I expect to see two different db connections. Is this an incorrect assumption?

Thats the correct documentation. It shows how to set different connection settings per target.
It changes when you change the target.

Have you tried closing the open tab before switching target?

I’ve followed the instructions closely several times and each time entering the second set of database connection options overwrites the first set I had entered.

Note 1: After entering the first set of conn options a conn is also automatically entered under under Database Manager even without the “Direct Connection” option selected. If that conn’s properties is opened up all fields are empty. Switching targets and entering the second conn options does not create a second “Direct Connection”.

Note 2: I’m using the latest version of Wappler and the instruction’s screen shots are somewhat different.

Note 3: Opening the conn’s json file in the code editor confirms only one set of connection info is entered and this is overwritten after switching targets and entering a new set of conn info.

Thanks, I tried this and it didn’t make any difference, the second set of connection options entered always overwrites the first set entered even when closing the json file, switching tagets, and then re-opening the json file (by clicking the connection’s name).

The direct connection is not created per target. It’s the server connect connection which is created per target. Direct connection is only used for database manager, not for server actions.

I was pointing out that direct connections were auto-magically being created…
As far as creating different connections for different targets (dev & production) I have been unable to do this in Wappler.

You first say:

Then you say:

So is direct connection created or not?

The connections per target are created as per the tutorial - in Server Connect. This is what you want different per target, not the direct connection. The connection in server connect is what is used in your website / on your pages.

There may be a misunderstanding in terminology so I apologize if my comments seems at odds.
But both quotes you pulled are accurate:
When trying to create two db connection options (dev & production) I noticed a direct connection was auto-magically being created after creating the first db connection (dev), but only on the first db connection attempts while following the tutorial. The second (production) attempts did not auto-magically create a direct connection.

Regardless of ‘direct connections’, the tutorial did not result in two db connections (under ‘globals’).
Hope this makes it clear. The tutorial does not work for me.

You don’t need two connections under globals. It’s one connection there and it’s supposed to be one connection! It’s details are different per target (server/user/pass etc)!

Right, one connection, this is what I meant.
It is creating one connection, but as I said, it will not create two different options pages, one for dev & one for prod. I followed the tute exactly and several times. Hope this is clear.

I tested this and everything seems to be fine with the two connection details per two different targets.
Maybe make sure that when you change the target, you also close the tab with the database connection settings:

and open the database connection again, when the target has changed. Probably this is just a refresh issue.

Already tried this per sorry_duh’s suggestion.
It didn’t work. Only one “connection detail” is saved.
Can you see two “connection details” and verify them in code somewhere?
When I open the connection’s json file there is only one “connection detail”.
This is not a refresh issue.

Here’s a short video, showing the process you can see that when changing the targets, the connection details also change:

1 Like

It didn’t work until after I installed the update to 5.1.1.
The json file must be closed and then reopened to display the 2 different “connection details”. I don’t know how this will affect using the app on in an actual project–big concerns here.
But the major issue which remains is neither connection test works.
If I create “direct connections” they do work.


It won’t affect your app. It’s a UI refresh issue and @George will check how can we improve this.

Ok, the refresh issue is one thing–hope that gets addressed, but what about the failure to connect to my databases? Like I said, the direct connection will work with the same credentials, but not the main global connection. What to do?

The direct connection connects to your database directly i.e. as if using a remote access, like when you use software like navicat to connect to it.

The connection in the Server Connect connects to your database from the server you’ve setup in the target. It uploads a connection script to the server and connects to the database from there. So there must be some issue either with your targets setup or some permissions issue.

Ok thanks for all your help.
Uploading a script to the web server may not ever work as it is hosted and I do not control it. I need to learn the details about this script. What is the filename, where is it trying to be saved to? How is Wappler then using this script to eventually connect to my database (again, it is hosted and has a lot of security). If I could understand exactly what Wappler is trying to do, and why, I might be able to work with my hosting provider to get a solution. Thanks

Then how did you set up your target in Wappler? Where is it pointing to? Is there an actual server running for your dev/prod target?