Environment Variables (Wappler UI)

Hi guys,

Just started working on a new project and I tried to use the Environment Variables for my DB Connection.
So, I’ve already set my Env Variables:

Then I set up a DB Connection using these Env Vars and clicked on TEST CONNECTION to check it.

A Failure message about “No such host is known” appered.

Anyway, I filled up all the Db Connection fields again with static values

and tested again and connection is OK this way…

Any idea what am I doing wrong?
Thanks in advance

Hi,

This might be a bug, I don’t think Wappler UI reads the environment variables.

I’m going to move your topic to the bug reports category, hopefully the team fixes it soon

1 Like

Thanks brother,

Anyway I go on with the stable static way and as soon as I have news about it I will apply the changes (or apply them in my new project.

Thanks anyway, chears

Have you added Environment variables with same name in Global under ENV?
You can check to create some dummy Server Connect with a single variable that will take one of your ENV variables and set an output.

Thanks for replying @Notum,

Done…


The output is correct.

But still I can’t explain what I’m doing wrong

Maybe I have to check my project settings because I have set my project to a subfolder of my domain.
Although all other links (bootstrap etc) works fine…

1 Like

Hi @sid,
Thanks for your reply!

Since I started using Wappler, I am working on 2 projects that none of them have gone online yet and I haven’t tested pulling data from DB.

I tried to follow the links to figure out what I have to do to solve my problem but no luck…
As far as i understand, I have to set 2 different DB Connections, one for local and one for production use.
And now I am wondering where I have to define which one will be used for each case…
I mean normally (no wappler involved, just pure php…) I would finish the project locally with Development Env.Vars and after uploading my files just update the values of ENV.Vars to the server…
Can somebody please give me some info on how to handle 2 DB Connections (1 per each target) in wappler?

Your understanding of DB connections in context of Wappler is a bit off.

Each project can have multiple targets.
But, each project needs just one DB connection - in Globals section of server action/api panel.

If you are using ENV, your DB connection will automatically be set based on local machine or production machine’s ENV settings.
The ENV values you have set in the Wappler UI, are useless for production environment.
You will have to identify how env variables and PHP work.

If you don’t use ENV for DB connection, you just have to select target and update values once for each target. You can finds docs for this in community.

Lastly, there is something called DB Manager. Again, you just need one connection here. But, it cannot be ENV as explained in the link I shared.
And it should always have credentials of dev DB, and not production, irrespective of target.
DB manager connection is only used for Wappler UI, it has not effect on deployment.

3 Likes

Thanks again @sid,

Perfect!
You were absolutely instructive and made it 100% clear brother.

Thank you very much

Targets means different destination folders, local machine, test deployment server, final/online hosting location.

But, “project” means the Wappler project folder on the local machine.

Correct?
“But, each project needs just one DB connection” is actually saying that each Wappler Project can ONLY USE 1 database connection. “needs” connotes that there is a minimum requirement of one connection but others may be added.

I’m confused by this declaration now. Setting up multiple database connections per target is now a default, is it not?

A target means a location (be it local or remote) where you can deploy your files. It can be a development target or a production one. It can be a local server running on your machine or a remote server on any hosting.

A project is not “the Wappler project folder on the local machine”. Your project includes everything related to the app/site you are working on incl. settings and everything. And the project does contain your local files also, they are part of it.

You just need one database connection defined for your projects. Of course you can have as many as you wish, but it does not make sense to have more than one connection, if you are connecting to a single database.
This one connection then can be adjusted with different login credentials per target. But it’s still one database connection definition.

Correct.

Needs = minimum 1 DB connection, if you want to use DB. If you don’t want to use DB in your project, it can be 0.

That was never the case, ever, from what I know, and neither is now. Maybe you are confusing what a DB connection in Wappler means with actual DB server.

Using a database connection is always my default. Always a super important part of building pages to connect and interact with a database ONLINE.
Testing may start with a local machine database.

So, I’ve been quite familiar with setting up database connections.
Which is why I had to get clarification on your terminology. :grin:

Still you need one connection, no need to create more for each target. One database connection per project with different credentials per target is what you need.
I see you’ve been a Wappler user since 2018 and before that also you used DMXzone extensions, where the process was the same.
Seems to me you already should have a clear view of “our terminology” :wink: