Problem fetching tables without a direct database connection

However, it is strange that with the URL address of that site, it works in others all projects (with Own Local Server) the local development target
In any case, I can’t change the Own Server to Wappler Server

It is impossible to change the local server, so I created a new project from scratch and now all connections work correctly
(Local, Staging, Production)
Thank you

Sorry Marzio, i don’t understand what do you mean.
Just setup your project and the different targets properly. Its been discussed in many topics already, including different topics you created about the same thing.

maybe I expressed myself badly
Wappler after creating a new project with Own Server, then no longer accepts the variation of the server
So I recreated the project with Wappler Server and or solved the problem

@Teodor

Hi Teodor
I’ve tried numerous times with different settings, but unfortunately I can’t get the project’s database connections to work
I start from the fact that I have two twin databases on the provider’s server, one intended for production and another intended for staging and possibly also for development
Here I report the setting of the project options and the 3 perfectly functioning targets

PROJECT OPTION

3 TARGET OK



The problem is that the remote database for production is the only one that works. If I use the Production target the database connects

REMOTE DATABASE FOR TARGET PRODUCTION - OK CONNECT

However, as far as databases for staging and development are concerned, I really can’t figure it out
I have a second database (also remto) connected to the subdomain used for staging
As far as the database for development is concerned, I really don’t know which solution to use. Create a new database for Wappler local server or use the same as staging.

I’m a little confused

You need only one connection created.
It’s explained in the docs how to change this single database connection settings PER TARGET:

What this tutorial shows:

  1. Switch to your local target

    • set the database connection settings for the local target
    • save
  2. Switch to your staging target

    • set the database connection settings for the staging target
    • save
  3. Switch to your remote target

    • set the database connection settings for the remote target
    • save

I really don’t know how to explain this process simpler than that. It’s already in the tutorial and i already sent this to you multiple times.

1 Like

but this is what I do, I have two remote databases available, with different names and passwords
I assigned the first to the Production target, the second I tried to assign to the Staging target and/or the Development target
but it doesn’t connect and produces an error
Your tutorial is perfect and I followed it to the letter

@Teodor

Sorry Teodor, but I followed your instructions and I’m sure I didn’t make a mistake, also because it’s very clear
However I just can’t setup a local database.
As I pointed out previously, I have three targets (Development, Staging, Production) and I have two remote databases available on the domain server.
I created three different database connections in Global:
db_production - database 1 (OK)
db_staging - database 2 (OK)
db_development - I can’t get it to work

I restarted Wappler several times and tried to match database 2 to db_development, but the error occurs
I really don’t know why it doesn’t work since it uses the same settings as Staging database 2
I really don’t know how to do it

Schermata 2024-04-18 alle 11.21.49

That’s totally the opposite of what i explained you. You should only have 1 (one) database connection in the project, no 2 or 3 or 10. Only one.
I really can’t help if you are doing exactly the opposite of what my posts say.

Sorry Teodor, maybe I expressed myself badly
The database is unique and is called db
then I have 3 different settings depending on the three targets
For each target, change the name and setting
If I choose the Production target it is OK (database 1)
If I choose the Staging target it is OK (database 2)
If I choose the Development target (database 2) ERROR

Try changing the address of the database to 127.0.0.1 instead of localhost

The same error

Then most probably the database connection details you are entering for the development target are wrong.

No, they are the same as the Staging target

Marzio … if your staging target is at some domain on a remote server, then trying to connect from the local server target won’t work with the same database details!

In fact I said that the two databases are located on a remote server
One for production and the other for staging and development
So it looks like I can’t use it for target development?

I am not sure if you understand how database connections work.

When your target is set to the remote server such as: https://my-remote-server.com and your database is hosted there, your connection uses localhost to connect to it, as it is local to this server. Your connection is made ON the remote server and is LOCAL to it.

When your target is on the local server on your machine, using localhost for database connection will look for a LOCAL database, which obviously is not there. If you want to connect to the database hosted on https://my-remote-server.com localhost won’t work…

ok, in fact it is like this but I thought that Wappler automatically managed a connection of this type
What I didn’t understand is whether there is still a possibility to connect the database also for target development, or whether I should give up

How would Wappler guess where your database is, when you enter localhost on your local server target?
The answer to your question is simple - you need to enter the remote connection details for the remote server database.

A diagram trying to explain how the connections work:

1 Like

Thank you for the explanation, very clear
But what I don’t know is how I can change the connection with Wappler.
The only item I can change is the Server address but if I enter the IP address of the remote server, it doesn’t work
Maybe it’s because this database can’t be managed remotely?