Skip to main content

Extensibility and Integration

 

OutSystems

Connect to an External Database

OutSystems integrates with your existing databases. This allows you to develop applications that access data in external databases using visual objects in Service Studio and without having to worry about data migration.

Integrating with external databases involves the following steps:

  1. Define a connection to the external database;
  2. Map tables or views in the external database to entities in an extension module;
  3. Configure the extension to use a database connection;
  4. Use the extension in your application.

For a list of supported external database engines, see the System Requirements.

Define a Connection to the External Database

To use tables and views from external databases, you need to create a database connection:

  1. In Service Center, under the tab Administration, click Database Connections;
  2. Click New Database Connection and fill in the fields to set up the connection to the external database.
    If you need to fine-tune the database connection, choose the option Advanced configuration. This allows you to define your own connection string;
  3. Click Test to check if the connection is working correctly.

The database user must have permissions to: List the necessary tables and views in the external database; Perform the operations Create, Read, Update, and Delete on those tables and views.

Map Tables or Views to Entities in an Extension Module

After configuring a database connection in Service Center, you must use Integration Studio to create an extension that maps the tables or views in the external database to OutSystems entities:

  1. In Integration Studio, connect to the environment where the database connection is configured;
  2. Create a new extension, right-click the Entities folder in the tree and select Connect to External Table or View...;
  3. Follow the steps of the wizard.

    Make sure that you:
    • Select the database connection configured previously;
    • Select the necessary tables and views;
    • Define a logical database name that you will use to connect the extension to a physical database connection in the next section.
  4. After closing the wizard, review the imported entity names, descriptions and data types for each attribute;
  5. Click the button 1-Click Publish to publish the extension module.
  6. After publishing the extension, OutSystems warns you that you still need to configure which database connection the extension will use.

Configure the Extension to Use a Database Connection

To configure which database connection the extension will use, click the Configure button in the 1-Click Publish window. The button opens a configuration page in Service Center:

  1. In Service Center, check that you are under the tab Factory, Extensions, your new extension, tab Operation;
  2. Associate the logical database name of the extension to the database connection that the extension will use in runtime.

In some cases you need to select the database based on runtime data. Typically, the applicable databases share the same schema but they contain different data.

In these scenarios you can use the action DatabaseConnection_SetConnectionStringForSession of the PlatformRuntime API.

Use the extension in your application

The extension is now ready to be used in OutSystems applications:

  1. In your application, click the button Manage Dependencies...;
  2. Add a dependency to the extension and select the entities that you will use in your application.

You can now use the entities of the extension to manipulate data in the external databases just like you do with the standard OutSystems entities.