Execute SQL query against PostgreSQL in SSIS

Introduction

ZappySys provides high-performance drag and drop connectors for PostgreSQL Integration. In this post you will see how to Execute SQL query against PostgreSQL in SSIS, in various SQL commands such as SELECT, INSERT, DROP, COPY, CREATE, etc using PostgreSQL Execute SQL Task can be used to execute DDL and DML statements for PostgreSQL without needing any extra driver. PostgreSQL is a powerful, open-source relational database with a strong reputation for reliability, feature robustness, and performance.

In nutshell, this post will focus on how to Execute SQL query against PostgreSQL in just a few clicks.

Prerequisite

  1. First, you will need to have SSIS installed
  2. Secondly, make sure to have SSDT
  3. Thirdly, You have obtained PostgreSQL Credential.
  4. Finally, do not forget to install ZappySys SSIS PowerPack

Component Mentioned in this article

What is PostgreSQL?

PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. The origins of PostgreSQL date back to 1986 as part of the POSTGRES project at the University of California at Berkeley and has more than 30 years of active development on the core platform.

PostgreSQL has earned a strong reputation for its proven architecture, reliability, data integrity, robust feature set, extensibility, and the dedication of the open source community behind the software to consistently deliver performant and innovative solutions. PostgreSQL runs on all major operating systems, has been ACID-compliant since 2001, and has powerful add-ons such as the popular PostGIS geospatial database extender. It is no surprise that PostgreSQL has become the open source relational database of choice for many people and organisations.

Getting started with using PostgreSQL has never been easier – pick a project you want to build, and let PostgreSQL safely and robustly store your data.

Download and Install PostgreSQL

Please go to below download link and download the Windows version Binary package and install it and follow the steps from the installer.

https://www.postgresql.org/download/

Download PostgreSQL

Download PostgreSQL

Create a PostgreSQL Database

  1. To do this, go to Start Menu and search for pgAdmin and we will first open the pgAdmin Panel.
    Open pgAdmin from Start Menu

    Open pgAdmin from Start Menu

  2. It will open the pgAdmin Panel in the system default browser. Select Server and Right-click on Databases to create a database.
    PostgreSQL Create Database

    PostgreSQL Create Database

  3. Now, Enter the Database name and click on Save to create it.
    Create PostgreSQL Database

    Create a PostgreSQL Database

Getting Started

In order to start, we will show several examples. ZappySys includes an SSIS PostgreSQL ExecuteSQL Task that will help you how to Create and Drop table by Execute SQL query against PostgreSQL in SSIS. ZS PostgreSQL ExecuteSQL Task support execute queries against PostgreSQL without ODBC driver, load query at runtime from variable, file or Direct value, 100% Managed code means its 32bit and 64bit compatible, you can issue COPY, UNLOAD commands very easily, Support for SQL Server 2017, 2016, 2014, 2012, 2008 (32/64 bit) and Click here to see articles related to PostgreSQL.

You can connect to your PostgreSQL database by entering your PostgreSQL credentials.

Execute SQL query against PostgreSQL in SSIS

Let’s start with an example. In this tutorial, we will learn how to Create and Drop table using SQL query against PostgreSQL server using ZS PostgreSQL ExecuteSQL Task.

  1. In order to connect to the PostgreSQL Database from SSIS, you will need Credentials. Ask your SysAdmin or responsible person to provide that to you.
  2. Once you finished the above steps, Open Visual Studio and Create New SSIS Package Project.
  3. In Visual Studio, drag and drop the ZS PostgreSQL ExecuteSql Task in the design surface.
    SSIS ZS PostgreSQL ExecuteSQL Task - Drag and Drop

    SSIS ZS PostgreSQL ExecuteSQL Task – Drag and Drop

  4. We need a PostgreSQL Database connection. Click here to create a connection.
  5. Now, double click on ZS PostgreSQL ExecuteSql Task to configure it.
  6. In the PostgreSQL ExecuteSql Task, add the following SQL code to DROP a table if it exists and CREATE a table named pg_equipment in the SQL Statement section.
    You can replace the table name from the following code.
    SSIS ZS PostgreSQL ExecuteSQL Task - Configure

    SSIS ZS PostgreSQL ExecuteSQL Task – Configure

  7. In the above step, you can Select Variable as Sql Source Type.
  8. Click OK to save ZS PostgreSQL ExecuteSql Task UI settings.
  9. Finally, Right Click on Task and Select Execute Task to run it.

Conclusion

After all, In this blog, we learned Execute SQL query against PostgreSQL in SSIS using ZS PostgreSQL ExecuteSQL Task. You can download SSIS PowerPack here to try many other scenarios not discussed in this blog along with 70+ other components.

References

Finally, you can use the following links for more information:

Posted in SSIS PostgreSQL ExecuteSQL Task and tagged , , , , , , , , .