PostgreSQL Reader - Haufe-Lexware/haufe.no-frills-transformation GitHub Wiki

Reading data from an PostgreSQL database

In order to read data from an PostgreSQL database, use the following source definition:

<Source config="[configuration]">postgres://[SQL query]</Source>

Any SQL query which is supported by PostgreSQL can be passed into the SQL Query parameter. All resulting fields will be interpreted as strings.

For the configuration, there are two possibilities:

  • Using a connection string directly
  • Using a connection string which is located in a text file

Using a connection string directly

Pass the connection string directly into the configuration of the source tag:

<Source config="Host=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;">postgres://select * from MyTable where wage &gt; 1000</Source>

Parameters can be used inside the connection string, if needed.

Please note the use the substitution of the greater (>, &gt;) operator in the SQL query (needed for XML compliance).

Using a connection string inside a text file

In order to read the connection string from a file, use the following syntax (using the @ character):

<Source config="@postgres_connection.txt">oracle://select * from MyTable where wage &gt; 1000</Source>

Sample content of the postgres_connection.txt file, also using a parameter (§env§):

Host=§env§;Database=myDataBase-§env§;User ID=myUsername;Password=myPassword;

Sample Connection Strings

See https://www.connectionstrings.com/postgresql/

⚠️ **GitHub.com Fallback** ⚠️