Load PostgreSQL Table Data to CSV File in SSIS

Introduction

ssis-PostgreSql-SourceZappySys provides high performance drag and drop connectors for PostgreSQL Integration. In this post you will see how to Load PostgreSQL Table Data to CSV File using SSIS PostgreSQL Source. PostgreSQL Source supports SQL language to query PostgreSQL data. PostgreSQL is a powerful, open source relational database with strong reputation for reliability, feature robustness, and performance.

In nutshell, this post will focus on how to Load PostgreSQL Table Data and write into CSV File using Trash Destination in few clicks. You can also use the CSV Destination instead of Trash destination if you wants more option like compressed file gzip (*.gz) or zip, wants to splitting the file by row count of file size and more.

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

Components 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/

ssis-PostgreSql-download

PostgreSQL Download

Create PostgreSQL Database and Table

  1. To do this, we will first open the pgAdmin Panel.
    Open pgAdmin

    Open PostgreSQL pgAdmin Panel

  2. It will open the pgAdmin Panel in the browser. Select Server and Right click on Databases to create database.
    PostgreSql Select Create Database

    PostgreSQL Select Create Database

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

    Create PostgreSQL Database

  4. Now select the created database under it expand Schemas and right click on Tables and click on create Table.
    PostgreSQL Select Create Table

    PostgreSQL Select Create Table

  5. Now enter the table name and go to columns tab.
    PostgreSQL Enter Table Name

    PostgreSQL Enter Table Name

  6. Add the columns by clicking add button and give the desire column name and select the datatype for the same.
    PostgreSQL Add Table Columns

    PostgreSQL Add Table Columns

  7. Now, let’s insert some data using Query Editor.
    PostgreSQL Insert Data in Table

    PostgreSQL Insert Data in Table

  8. That’s it, now let’s move forward to read the data from this table using SSIS PostgreSQL Source in the next the section.
    PostgreSQL Select Query Data

    PostgreSQL Select Query Data

Getting Started

In order to start, we will show several examples. ZappySys includes an SSIS PostgreSQL Source that will help you extract large amount of data from a PostgreSQL Database. PostgreSQL Source supports Multiple modes (i.e. Table or Query) to read data from PostgreSQL Database and many more operations. Here we are showing you is, How to read data from PostgreSQL collection.

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

Load PostgreSQL Table Data to CSV File

Let´s start with an example. In this SSIS PostgreSQL Source Task example, we will load the PostgreSQL table data to CSV file.

  1. First of All, Drag and drop Data Flow Task from SSIS Toolbox and double click it to edit.
    Drag and Drop SSIS Data Flow Task from SSIS Toolbox

    Drag and Drop : Data Flow Task from SSIS Toolbox

  2. Drag and Drop PostgreSQL Source Task from the SSIS Toolbox and double click on it to edit it.
    PostgreSQL Source

    PostgreSQL Source

  3. Let’s create a connection for PostgreSQL Database.
    Create PostgreSQL Database Connection

    Create PostgreSQL Database Connection

  4. Let’s select the Table mode and select the table and click on preview.
    PostgreSQL Table Preview

    PostgreSQL Table Preview

  5. You can also use the query mode to filter the data and do more operation using query. You can find our several Examples also by clicking on <<View Examples>>.
    PostgreSQL Query Preview

    PostgreSQL Query Preview

  6. Now let’s add Trash destination Task and edit it and enter the CSV File Path.
    Trash Destination : Setup CSV File Path

    Trash Destination : Setup CSV File Path

  7. That’s it now execute the package and it will load data from PostgreSQL Table to CSV File.
    PostgreSQL : CSV Data

    PostgreSQL : CSV Data

Conclusion

Above all, in this blog, we learned how to Read data from PostgreSQL in SSIS. We used SSIS PostgreSQL Source to read the data from PostgreSQL Table and load data into CSV File. 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 CSV File Destination, SSIS PostgreSql Connection, SSIS PostgreSQL Source and tagged , , .