Open Database connection
Opens a database connection using a provider name and a connection string that can be used for Run Query, Run Non Query, Start Transaction or Add data Table. To close the connection we need to Close Database connection activity.
#
Designer Properties- Provider Name The provider used to connect to the database. For instance, in the example below we use Odbc to connect to a postgres database.
- Connection string Database connection string. As an example, for the example below the format is "Driver={PostgreSQL ODBC Driver(UNICODE)};Server=127.0.0.1;Port=5432;Database=postgres;UID=postgres;PWD=yourpassword"
- Out Connection The generated database connection. To simplify the process, we generate the connection variable automatically, but it can be changed under Variable tab at the bottom of the workflow.
#
Properties#
InputSee Designer Properties above.
#
General PropertiesSee General Properties.
#
MiscSee Misc.
#
Out ErrorSee Out Error.
#
Output PropertiesSee Designer Properties above.
#
ExampleOpen database connection and add table
In this example we open a database connection to a postgres database, add the content of data table to a database table and display the content of the resulting database table.
In this case we used "Odbc Data Provider" as provider name.
To connect to postgres database, we had to
- Install postgres from here https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
- Using Stack Builder installed by postgres (to find it, just type stack builder in windows start), select the database and press the next button to install the drivers as in the below screenshot.
- Use a Connection string like the following "Driver={PostgreSQL ODBC Driver(UNICODE)};Server=127.0.0.1;Port=5432;Database=postgres;UID=postgres;PWD=". Just make sure you update the password or any other relevant field in the above connection string.