Server connect - dynamic connections


#1

Does anyone know of a way that variables being able to be used for the connection parameters in Server Connect?

I have a database that contains the connection details for customers’ own databases where their data is kept (with matching DB schema). What I would like to do is:

  1. Make a connection to my DB
  2. Get connection details via a query
  3. Use the collected details to make a new connection (which can then be queried etc.)

I can perform 1&2 but am stuck on 3.
I have tried setting the details as a value and them manually editing the connection script (outside of Wappler) with {{valuename}} in place of the host address, username, password and DB name. The connection settings screen won’t allow values to be saved as the validation fails (hence editing outside).

Any help would be gratefully received.


#2

Hello @equaliser01 and welcome to Wappler community!

I am afraid that this is not possible. The connection should be created via the UI, entering the specific details, this then saves it as a separate file. Then you can select it in the UI of your server actions for the steps which need this connection.


#3

Hi Teodor,
Thank you for coming back to me. I was hoping to be able to make a duplicate of a connection file and alter the connectionString, adding the value placeholders in.

Unfortunately, for what I need it for, it makes Wappler unusable without it. I will keep an eye on future announcements to see if it is something you allow because I was really enjoying getting to know Wappler up to this problem.

Have a wonderful day.
Ben


#4

@equaliser01
Can you explain the use case of this request? When/in what casees do you need dynamic database connections, as this could be quite a big problem if the database structure changes?


#5

Hi Teodor,
Sorry for not replying sooner. I didn’t see your response.

I have a central database that contains authorisation and configuration data to my web platform. The platform then connects with customer’s databases (they can install their own MySQL DB on their own server) to retrieve the specific data for that customer (in my case schools). That way the ownership of data and significant majority of responsibility under GDPR lies with the customer.

I appreciate that differing DB structures could cause problems so I have a chronjob running that synchronises the database structure periodically so that any updates are reflected for all the customers’ DBs.

The reason I can’t have the configuration/authentication in the customers’ DB is that individual users (e.g. parents, or staff) could be involved in multiple schools. My system acts as the bridge allowing a user to switch between schools/roles easily and transparently. In some cases, we consolidate the date for several schools (e.g. when they are part of a group of schools).

If you were to look at implementing expressions in Server Connect, I would have though you could set the connection fields to allow expressions but have separate fields for a ‘known connection’ (static connection to a test DB) which could be used for field mapping and testing.

Without the option to use expressions in Server Connect, I am looking at whether I could use API connect to do what I need. My trial has expired, though, would it be possible to get a short extension to test it before purchase?

Thanks for your help
Ben