Postgres

target-postgres (meltanolabs variant)🥇

PostgreSQL database loader

The target-postgres loader sends data into Postgres after it was pulled from a source using an extractor

Alternate Implementations

Getting Started

Prerequisites

If you haven't already, follow the initial steps of the Getting Started guide:

  1. Install Meltano
  2. Create your Meltano project

Installation and configuration

  1. Add the target-postgres loader to your project using
    meltano add
    :
  2. meltano add loader target-postgres
  3. Configure the target-postgres settings using
    meltano config
    :
  4. meltano config target-postgres set --interactive

Next steps

If you run into any issues, learn how to get help.

Capabilities

The current capabilities for target-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:

  • about
  • hard-delete
  • schema-flattening
  • stream-maps

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:

You can also list these settings using

meltano config
with the list subcommand:

meltano config target-postgres list

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.

Activate Version (activate_version)

  • Environment variable: TARGET_POSTGRES_ACTIVATE_VERSION
  • Default Value: true

If set to false, the tap will ignore activate version messages. If set to true, add_record_metadata must be set to true as well.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set activate_version [value]

Database (database)

  • Environment variable: TARGET_POSTGRES_DATABASE

Database name. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set database [value]

Dialect+Driver (dialect+driver)

  • Environment variable: TARGET_POSTGRES_DIALECT+DRIVER
  • Default Value: postgresql+psycopg2

Dialect+driver see https://docs.sqlalchemy.org/en/20/core/engines.html. Generally just leave this alone. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set dialect+driver [value]

Host (host)

  • Environment variable: TARGET_POSTGRES_HOST

Hostname for postgres instance. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set host [value]

Interpret Content Encoding (interpret_content_encoding)

  • Environment variable: TARGET_POSTGRES_INTERPRET_CONTENT_ENCODING
  • Default Value: false

If set to true, the target will interpret the content encoding of the schema to determine how to store the data. Using this option may result in a more efficient storage of the data but may also result in an error if the data is not encoded as expected.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set interpret_content_encoding [value]

Password (password)

  • Environment variable: TARGET_POSTGRES_PASSWORD

Password used to authenticate. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set password [value]

Port (port)

  • Environment variable: TARGET_POSTGRES_PORT
  • Default Value: 5432

The port on which postgres is awaiting connection. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set port [value]

Sqlalchemy URL (sqlalchemy_url)

  • Environment variable: TARGET_POSTGRES_SQLALCHEMY_URL

SQLAlchemy connection string. This will override using host, user, password, port, dialect, and all ssl settings. Note that you must escape password special characters properly. See https://docs.sqlalchemy.org/en/20/core/engines.html#escaping-special-characters-such-as-signs-in-passwords


Configure this setting directly using the following Meltano command:

meltano config target-postgres set sqlalchemy_url [value]

SSH Tunnel Enable (ssh_tunnel.enable)

  • Environment variable: TARGET_POSTGRES_SSH_TUNNEL_ENABLE
  • Default Value: false

Enable an ssh tunnel (also known as bastion host), see the other ssh_tunnel.* properties for more details


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssh_tunnel enable [value]

SSH Tunnel Host (ssh_tunnel.host)

  • Environment variable: TARGET_POSTGRES_SSH_TUNNEL_HOST

Host of the bastion host, this is the host we'll connect to via ssh


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssh_tunnel host [value]

SSH Tunnel Port (ssh_tunnel.port)

  • Environment variable: TARGET_POSTGRES_SSH_TUNNEL_PORT
  • Default Value: 22

Port to connect to bastion host


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssh_tunnel port [value]

SSH Tunnel Private Key (ssh_tunnel.private_key)

  • Environment variable: TARGET_POSTGRES_SSH_TUNNEL_PRIVATE_KEY

Private Key for authentication to the bastion host


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssh_tunnel private_key [value]

SSH Tunnel Private Key Password (ssh_tunnel.private_key_password)

  • Environment variable: TARGET_POSTGRES_SSH_TUNNEL_PRIVATE_KEY_PASSWORD

Private Key Password, leave None if no password is set


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssh_tunnel private_key_password [value]

SSH Tunnel Username (ssh_tunnel.username)

  • Environment variable: TARGET_POSTGRES_SSH_TUNNEL_USERNAME

Username to connect to bastion host


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssh_tunnel username [value]

SSL Certificate Authority (ssl_certificate_authority)

  • Environment variable: TARGET_POSTGRES_SSL_CERTIFICATE_AUTHORITY
  • Default Value: ~/.postgresql/root.crl

The certificate authority that should be used to verify the server's identity. Can be provided either as the certificate itself (in .env) or as a filepath to the certificate. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssl_certificate_authority [value]

SSL Client Certificate (ssl_client_certificate)

  • Environment variable: TARGET_POSTGRES_SSL_CLIENT_CERTIFICATE
  • Default Value: ~/.postgresql/postgresql.crt

The certificate that should be used to verify your identity to the server. Can be provided either as the certificate itself (in .env) or as a filepath to the certificate. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssl_client_certificate [value]

SSL Client Certificate Enable (ssl_client_certificate_enable)

  • Environment variable: TARGET_POSTGRES_SSL_CLIENT_CERTIFICATE_ENABLE
  • Default Value: false

Whether or not to provide client-side certificates as a method of authentication to the server. Use ssl_client_certificate and ssl_client_private_key for further customization. To use SSL to verify the server's identity, use ssl_enable instead. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssl_client_certificate_enable [value]

SSL Client Private Key (ssl_client_private_key)

  • Environment variable: TARGET_POSTGRES_SSL_CLIENT_PRIVATE_KEY
  • Default Value: ~/.postgresql/postgresql.key

The private key for the certificate you provided. Can be provided either as the certificate itself (in .env) or as a filepath to the certificate. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssl_client_private_key [value]

SSL Enable (ssl_enable)

  • Environment variable: TARGET_POSTGRES_SSL_ENABLE
  • Default Value: false

Whether or not to use ssl to verify the server's identity. Use ssl_certificate_authority and ssl_mode for further customization. To use a client certificate to authenticate yourself to the server, use ssl_client_certificate_enable instead. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssl_enable [value]

SSL Mode (ssl_mode)

  • Environment variable: TARGET_POSTGRES_SSL_MODE
  • Default Value: verify-full

SSL Protection method, see postgres documentation for more information. Must be one of disable, allow, prefer, require, verify-ca, or verify-full. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssl_mode [value]

SSL Storage Directory (ssl_storage_directory)

  • Environment variable: TARGET_POSTGRES_SSL_STORAGE_DIRECTORY
  • Default Value: .secrets

The folder in which to store SSL certificates provided as raw values. When a certificate/key is provided as a raw value instead of as a filepath, it must be written to a file before it can be used. This configuration option determines where that file is created.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set ssl_storage_directory [value]

User (user)

  • Environment variable: TARGET_POSTGRES_USER

User name used to authenticate. Note if sqlalchemy_url is set this will be ignored.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set user [value]
Expand To Show SDK Settings

Add Record Metadata (add_record_metadata)

  • Environment variable: TARGET_POSTGRES_ADD_RECORD_METADATA
  • Default Value: true

Note that this must be enabled for activate_version to work!This adds _sdc_extracted_at, _sdc_batched_at, and more to every table. See https://sdk.meltano.com/en/latest/implementation/record_metadata.html for more information.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set add_record_metadata [value]

Default Target Schema (default_target_schema)

  • Environment variable: TARGET_POSTGRES_DEFAULT_TARGET_SCHEMA
  • Default Value: $MELTANO_EXTRACT__LOAD_SCHEMA

Postgres schema to send data to, example: tap-clickup


Configure this setting directly using the following Meltano command:

meltano config target-postgres set default_target_schema [value]

Faker Config Locale (faker_config.locale)

  • Environment variable: TARGET_POSTGRES_FAKER_CONFIG_LOCALE

One or more LCID locale strings to produce localized output for: https://faker.readthedocs.io/en/master/#localization


Configure this setting directly using the following Meltano command:

meltano config target-postgres set faker_config locale [value]

Faker Config Seed (faker_config.seed)

  • Environment variable: TARGET_POSTGRES_FAKER_CONFIG_SEED

Value to seed the Faker generator for deterministic output: https://faker.readthedocs.io/en/master/#seeding-the-generator


Configure this setting directly using the following Meltano command:

meltano config target-postgres set faker_config seed [value]

Flattening Enabled (flattening_enabled)

  • Environment variable: TARGET_POSTGRES_FLATTENING_ENABLED

'True' to enable schema flattening and automatically expand nested properties.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set flattening_enabled [value]

Flattening Max Depth (flattening_max_depth)

  • Environment variable: TARGET_POSTGRES_FLATTENING_MAX_DEPTH

The max depth to flatten schemas.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set flattening_max_depth [value]

Hard Delete (hard_delete)

  • Environment variable: TARGET_POSTGRES_HARD_DELETE
  • Default Value: false

When activate version is sent from a tap this specefies if we should delete the records that don't match, or mark them with a date in the _sdc_deleted_at column. This config option is ignored if activate_version is set to false.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set hard_delete [value]

Load Method (load_method)

  • Environment variable: TARGET_POSTGRES_LOAD_METHOD
  • Default Value: append-only

The method to use when loading data into the destination. append-only will always write all input records whether that records already exists or not. upsert will update existing records and insert new records. overwrite will delete all existing records and insert all input records.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set load_method [value]

Stream Map Config (stream_map_config)

  • Environment variable: TARGET_POSTGRES_STREAM_MAP_CONFIG

User-defined config values to be used within map expressions.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set stream_map_config [value]

Stream Maps (stream_maps)

  • Environment variable: TARGET_POSTGRES_STREAM_MAPS

Config object for stream maps capability. For more information check out Stream Maps.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set stream_maps [value]

Validate Records (validate_records)

  • Environment variable: TARGET_POSTGRES_VALIDATE_RECORDS
  • Default Value: true

Whether to validate the schema of the incoming streams.


Configure this setting directly using the following Meltano command:

meltano config target-postgres set validate_records [value]

Something missing?

This page is generated from a YAML file that you can contribute changes to.

Edit it on GitHub!

Looking for help?

If you're having trouble getting the target-postgres loader to work, look for an existing issue in its repository, file a new issue, or join the Meltano Slack community and ask for help in the
#plugins-general
channel.

Install

meltano add loader target-postgres

Maintenance Status

  • Maintenance Status
  • Built with the Meltano SDK

Repo

https://github.com/MeltanoLabs/target-postgres
  • Stars
  • Forks
  • Last Commit Date
  • Open Issues
  • Open PRs
  • Contributors
  • License

Maintainer

  • Meltano

Meltano Stats

  • Total Executions (Last 3 Months)
  • Projects (Last 3 Months)

PyPI Stats

  • PyPI Downloads
  • PyPI Package Version

Keywords

  • meltano_sdkdatabase