Creating a database connection using an API

Creating a database connection using an API

  

In ServiceCenter you can create an database connection using the screens, but this is a manual job which i like to automate.

When creating a new application sometimes we need also a new database connection. This connection should exists on a site before deploying a application which is using this connection. In Our Company we have >1000 production sites for the same application. How can I distribute the database connection to all these sites.

My Idea is to create a dummy application which creates this database connection and deploy this application to all the sites.

Is there an API which I can use to create a database connection, or is there an other way to create an database connection from the command line.

I hope someone has a solution so this don't have to create the database connection manually on all the sites.

Hi Fred,

Lets me understand you use case better. All connections will use the same database model? So , you need just change the connections strings in runtime? 

If it is this case, you can use the native Extension PlatformRuntime_API. There is this action there:

'DatabaseConnection_SetConnectionStringForSession'
Switches a Database Connection from one database to another at runtime and in the current Session.
There are some conditions to which you have to pay attention to when using this action:
 - If there is a single query that uses the Database Connection with the old database before this action is executed, the switch to the new database will not happen until the end of the current request. Only in a next request the database switch becomes effective.
 - The Connection String must connect to a database with the same type (e.g. Oracle, SQL Server, MySQL) as the one configured in Service Center for the Database Connection.
 - Your license must include the Platform Extensibility APIs feature.



Best regards

Fabio

Hi Fabio,

Thanks for your answer, but this is not the case. All >1000 site are different outsystems sites with there own outsystems installations. The hard and software of all the sites is the same.

The applications ar using external entities and every application has his own database connection.

Before deploying an application to a site, the database connection should be there. So I have to find a way to automate the creation of the database connections. 

We are not switching connections at runtime.

Regards,
Fred.