Database queries not coming up

Hi, when I do a dynamic element on my page that is based on a SQL query (for example, a Bootstrap table generator or a dynamic dropdown), no data is populated either in Wappler or in the browser. However, the column names can be retrieved, just not the values.

Chrome shows me the following error - I am using a MySQL database. Is it a permissions/access problem? “Test connection” in Wappler shows no issues.

I followed the instructions to troubleshoot from this link (https://docs.wappler.io/t/debugging-server-connect-errors/2857) and found the additional error details as follows:

Edit to add more background if useful:
My SQL database is hosted locally - see connection parameters:
MySQL connection details

I’ve matched this in the Wappler setup (tried both “localhost” and “127.0.0.1” as host name and both have the same result):

Hi there, does anyone have any suggestions on this? For some reason I can’t get the database query data to generate when using a Wappler project linked to Docker, but I can do it when using local Wappler hosting. Would greatly appreciate any help!

The direct database connection is used when Wappler (The actual editor on your local machine) interacts with the database. If that is working, leave it as-is.

The connection string that is used when running your app in a browser, is under Globals > Database Connections.

Thanks Ken. Sorry, the issue is that both the view in Wappler editor and in the browser are the same. They both return the column names but do not return any data.

Really not sure what to do or how to troubleshoot. I’ve google searched a fair bit and tried modifying the config and ports specified in both the .yml and database .json files from the default settings, but none of that has worked either. It’s really strange since the connection works right up until Wappler/the browser needs to display the data contained in my database tables.

Like Ken said before:
Have you defined the db in your globals ?
(go to workflows -> globals -> database connection -> right click and add connection)

It appears you are using a MySQL 8 database, but you have chosen MySQL / MariaDB in you settings. The password encryption defaults changed on version 8, so you should probably be using MySQL 8 in Wappler.

Thanks @franse and @mebeingken. I had tried these before but that doesn’t work. I even started a fresh project and tried these again just to check that I didn’t do anything wrong.

See screenshots below:
MySQL8 setup in Database Manager:

Global DB Connection (mirrors Database Manager setup by default):

Still no data coming through in my table in Wappler editor:

Still a 500 ECONNREFUSED error in debugger:

Really can’t figure out what’s going on… I’ve tried everything I can think of…

Please clarify your setup. Web server is docker, or something else? Database is in docker or something else?

Hi Ken, yes the server is docker. When I select “local wappler hosting” I do not have this problem.

Sorry, not sure how to include the database in docker. It’s a MySQL database on localhost at port 3306, the default when setting up a fresh database within the MySQL interface. I’m not familiar with docker and containers - I did have a read of some documents about how to include databases within docker containers and involved running some command prompts in terminal, but it went over my head to be honest. I don’t have an IT background but do have some limited tech knowledge.

When you edit or create the target settings for your docker target, you can specify a database. In doing so it will be creating a database server inside your docker container, paired with your web server.

When you create another docker target and do the same, it will also have a database server that is completely separate from the other target.

In using docker you do not need the local database server that is on your local machine and outside of docker.

Thank you, that is working now! Does that mean that I am unable to connect to a database hosted on my local machine using Docker?

It is a bit more complicated. Try the solutions here: https://www.howtogeek.com/devops/how-to-connect-to-localhost-within-a-docker-container/