Db database connection doesn't allow direct database connection

Wappler Version : 3.9.7
Operating System : Windows 10
Server Model: Node JS
Database Type: MySQL
Hosting Type: Digital Ocean

Expected behavior

What do you think should happen?

I expect to be able to use a “Direct Database Connection” using db - the default database connection defined in Docker.

Actual behavior

What actually happens?

After pressing the “Direct Database Connection” I get the following message in the screen:

But in the project settings for the target, in the Database section, I don’t have the fields to input the information needed to connect to the Digital Ocean managed database.

Please advise how to proceed

The project settings for Docker with a DB is to set one up as part of the Docker build; you don’t need this if you have an external one to connect to.

Set up the docker project without a DB. Then you can add a database connection in Server Connect (and choose to create a direct connection)

1 Like

Hi bpj,

I have the Project Setting Target with the Database option at “None”. See screen below, yet the message is the same as I indicated at the beginning of the thread

Best.

Jay

Add the connection in Server Actions

As you can see in the first screen above, I have already created another database connection that I called “pps_remote”. I can use that connection to connect to a remote database in Digital Ocean. But with the “pps_remote” connection I am running into problems to insert data using forms with wappler under docker. I am just trying see if I can use the default docker connection to connect to a remote database, so that I don’t run into the insert data problems.

Hi Jay,
What is the issue inserting, you haven’t mentioned it until now? I have been using external DB connections with Docker in quite a few projects and can’t think of any problems inserting records.

OK, I created a sandbox project to have the minimum number of moving parts.

  1. I created a new Database Connection with a MySQL8 Digital Ocean database called DO, The database tests OK, see below:
  2. In the project settings I have a docker hosting with Nodejs. In the target, I have Database None, the following setup:
  3. With workbench I have access to the database, modify the schema, add/edit fields, etc
  4. I have created the simplest of APIs, just to insert data following Wapplers documentation:
  5. I fill the form I have created with info to insert:
    image
  6. But the fields don’t get inserted in the database…

    This is the problem I was having with the app I was developing, now in the sandbox too,
    Hope it helps.
    Best.
    Jay

Do you have a link to the page so I can have a look? (or is it just local)

http://159.65.226.41:90/

The form is pointing to /api/insert%20data but that doesn’t exist. If you open the browser dev tools (right click -> inspect) and look for the Network tab, you’ll see the request trying when you submit the form.

Check that the routing to your server connect file from the form on the page is correct or link the server connect form directly to the action.

Hi bpj, indeed the form is pointing to /api/insert%20data:

You are correct about the error message in the dev tools. But, where should it be pointing to? I thought I was following Wappler’s documentation.

I generally try to avoid using spaces in action file names - you could try that. Use camelcase or underscores

I generally try to avoid using spaces in action file names - you could try that. Use camelcase or underscores

Once you change the name you’ll need to re-link the form

Ok, I have changed the name to “insert” and re-linked the form, saved changes, exited wappler, started it again and I have the screen below:

Yet, the record doesn’t get inserted in the database and the error in the developer tools I get is:

  1. {status: “404”, message: “/api/insert%20data not found.”}

  2. message: “/api/insert%20data not found.”

  3. status: “404”


The change of name and action in the server connect form didn’t take effect. Surely this is a bug.

Did you re-publish the files? Your published form is still showing a link to api/insert%20data
image
rather than api/insert (the new name)

I just tried renaming a server action in a NodeJS project and re-linking it and it all worked fine. What does the form show in code view in Wappler?
e.g.

Yes, I republished it multiple times, please find below the page code:

Sorry to double check, but you definitely saved the file and published the page to the target at 159.65.226.41:90?

I’ve just cleared my caches and reloaded and the form is still pointing to the api file with the space in the name

Yes I have. Including turning off the computer and re publishing. I had the same doubts…

Something is not getting published. Try doing a full publish rather than a save if you haven’t yet.

I visited the page for the first time just now so it’s not a cache issue. Still pointing to file with space.

I would also try deleting the page from the remote server completely. Go to the page and make sure it’s gone. Then republish it.

1 Like