The target-postgres Meltano loader pulls data from PostgreSQL that can then be sent to a destination using a loader.
Other Available Variants
- datamill-co
- meltano
- meltanolabs
- transferwise (default)
Getting Started
Prerequisites
If you haven't already, follow the initial steps of the Getting Started guide:
Installation and configuration
-
Add the target-postgres loader to your project
using
:meltano add
-
Configure the target-postgres settings using
:meltano config
meltano add loader target-postgres
meltano config target-postgres set --interactive
Next steps
Follow the remaining steps of the Getting Started guide:
If you run into any issues, learn how to get help.
Troubleshooting
ld
, clang
, lssl
, or linker
Errors
If you have an error message like:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1
error: command 'clang' failed with exit status 1
These error messages indicates that there is a problem installing OpenSSL.
This Stack Overflow answer
has specific recommendations on setting the LDFLAGS
and/or CPPFLAGS
environment variables.
Set those prior to running meltano add loader target-postgres
.
Capabilities
The current capabilities fortarget-postgres
may have been automatically set when originally added to the Hub. Please review the
capabilities when using this loader. If you find they are out of date, please
consider updating them by making a pull request to the YAML file that defines the
capabilities for this loader.This plugin has the following capabilities:
You can
override these capabilities or specify additional ones
in your meltano.yml
by adding the capabilities
key.
Settings
The
target-postgres
settings that are known to Meltano are documented below. To quickly
find the setting you're looking for, click on any setting name from the list:
host
port
user
password
dbname
ssl
default_target_schema
batch_size_rows
flush_all_streams
parallelism
parallelism_max
default_target_schema_select_permission
schema_mapping
add_metadata_columns
hard_delete
data_flattening_max_level
primary_key_required
validate_records
temp_dir
You can
override these settings or specify additional ones
in your meltano.yml
by adding the settings
key.
Please consider adding any settings you have defined locally to this definition on MeltanoHub by making a pull request to the YAML file that defines the settings for this plugin.
Host (host)
-
Environment variable:
TARGET_POSTGRES_HOST
-
Default Value:
localhost
PostgreSQL host
Port (port)
-
Environment variable:
TARGET_POSTGRES_PORT
-
Default Value:
5432
PostgreSQL port
User (user)
-
Environment variable:
TARGET_POSTGRES_USER
PostgreSQL user
Password (password)
-
Environment variable:
TARGET_POSTGRES_PASSWORD
PostgreSQL password
Database Name (dbname)
-
Environment variable:
TARGET_POSTGRES_DBNAME
PostgreSQL database name
SSL (ssl)
-
Environment variable:
TARGET_POSTGRES_SSL
-
Default Value:
false
Using SSL via postgres sslmode='require'
option.
If the server does not accept SSL connections or the client certificate is not recognized the connection will fail.
Default Target Schema (default_target_schema)
-
Environment variable:
TARGET_POSTGRES_DEFAULT_TARGET_SCHEMA
-
Default Value:
$MELTANO_EXTRACT__LOAD_SCHEMA
Note that $MELTANO_EXTRACT__LOAD_SCHEMA
will expand to the value of the load_schema
extra for the extractor used in the pipeline, which defaults to the extractor's namespace, e.g. tap_gitlab
for tap-gitlab
.
Name of the schema where the tables will be created. If schema_mapping
is not defined then every stream sent by the tap is loaded into this schema.
Batch Size Rows (batch_size_rows)
-
Environment variable:
TARGET_POSTGRES_BATCH_SIZE_ROWS
-
Default Value:
100000
Maximum number of rows in each batch. At the end of each batch, the rows in the batch are loaded into Postgres.
Flush All Streams (flush_all_streams)
-
Environment variable:
TARGET_POSTGRES_FLUSH_ALL_STREAMS
-
Default Value:
false
Flush and load every stream into Postgres when one batch is full. Warning: This may trigger the COPY command to use files with low number of records.
Parallelism (parallelism)
-
Environment variable:
TARGET_POSTGRES_PARALLELISM
-
Default Value:
0
The number of threads used to flush tables. 0 will create a thread for each stream, up to parallelism_max. -1 will create a thread for each CPU core. Any other positive number will create that number of threads, up to parallelism_max.
Max Parallelism (parallelism_max)
-
Environment variable:
TARGET_POSTGRES_PARALLELISM_MAX
-
Default Value:
16
Max number of parallel threads to use when flushing tables.
Default Target Schema Select Permission (default_target_schema_select_permission)
-
Environment variable:
TARGET_POSTGRES_DEFAULT_TARGET_SCHEMA_SELECT_PERMISSION
Grant USAGE privilege on newly created schemas and grant SELECT privilege on newly created tables to a specific role or a list of roles. If schema_mapping
is not defined then every stream sent by the tap is granted accordingly.
Schema Mapping (schema_mapping)
-
Environment variable:
TARGET_POSTGRES_SCHEMA_MAPPING
Useful if you want to load multiple streams from one tap to multiple Postgres schemas.
If the tap sends the stream_id
in <schema_name>-<table_name>
format then this option overwrites the default_target_schema
value. Note,
that using schema_mapping
you can overwrite the default_target_schema_select_permission
value to grant SELECT permissions to different groups per schemas or optionally
you can create indices automatically for the replicated tables.
Example structure (as YAML):
schema_mapping:
my_tap_stream_id:
target_schema: my_postgres_schema
target_schema_select_permissions: [ "role_with_select_privs" ]
indices: ["column_1", "column_2s"]
Add Metadata Columns (add_metadata_columns)
-
Environment variable:
TARGET_POSTGRES_ADD_METADATA_COLUMNS
-
Default Value:
false
Useful if you want to load multiple streams from one tap to multiple Postgres schemas.
If the tap sends the stream_id
in <schema_name>-<table_name>
format then this option overwrites the default_target_schema
value.
Note, that using schema_mapping
you can overwrite the default_target_schema_select_permission
value to grant SELECT permissions to different groups per schemas or optionally you can create indices automatically for the replicated tables.
This setting can hold an object mapping source schema names to objects with target_schema
and (optionally) target_schema_select_permissions
and indices
keys.
Hard Delete (hard_delete)
-
Environment variable:
TARGET_POSTGRES_HARD_DELETE
-
Default Value:
false
When hard_delete
option is true then DELETE SQL commands will be performed in Postgres to delete rows in tables. It's achieved by continuously checking the _SDC_DELETED_AT
metadata column sent by the singer tap. Due to deleting rows requires metadata columns, hard_delete
option automatically enables the add_metadata_columns
option as well.
Data Flattening Max Level (data_flattening_max_level)
-
Environment variable:
TARGET_POSTGRES_DATA_FLATTENING_MAX_LEVEL
-
Default Value:
0
Object type `RECORD`` items from taps can be transformed to flattened columns by creating columns automatically. When value is 0 (default) then flattening functionality is turned off.
Primary Key Required (primary_key_required)
-
Environment variable:
TARGET_POSTGRES_PRIMARY_KEY_REQUIRED
-
Default Value:
true
Log based and Incremental replications on tables with no Primary Key cause duplicates when merging UPDATE events. When set to true, stop loading data if no Primary Key is defined.
Validate Records (validate_records)
-
Environment variable:
TARGET_POSTGRES_VALIDATE_RECORDS
-
Default Value:
false
Validate every single record message to the corresponding JSON schema. This option is disabled by default and invalid RECORD messages will fail only at load time by Postgres. Enabling this option will detect invalid records earlier but could cause performance degradation.
Temporary Directory (temp_dir)
-
Environment variable:
TARGET_POSTGRES_TEMP_DIR
(Default: platform-dependent) Directory of temporary CSV files with RECORD messages.
Something missing?
This page is generated from a YAML file that you can contribute changes to.
Edit it on GitHub!Looking for help?
#plugins-general
channel.
Install
meltano add loader target-postgres
Homepage
Maintenance Status
Meltano Stats
Keywords