百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

target-postgres

> 数据库
开源

一个用于 Postgres 的 Singer.io 目标

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个用于 Postgres 的 Singer.io 目标

Target Postgres

A Singer postgres target, for use with Singer streams generated by Singer taps.

Features

  • Creates SQL tables for Singer streams
  • Denests objects flattening them into the parent object's table
  • Denests rows into separate tables
  • Adds columns and sub-tables as new fields are added to the stream JSON Schema
  • Full stream replication via record version and ACTIVATE_VERSION messages.

Install

  1. Add libpq dependency
bash
# macos
brew install postgresql
bash
# ubuntu
sudo apt install libpq-dev
  1. install singer-target-postgres
bash
pip install singer-target-postgres

Usage

  1. Follow the Singer.io Best Practices for setting up separate tap and target virtualenvs to avoid version conflicts.

  2. Create a config file at ~/singer.io/target_postgres_config.json with postgres connection information and target postgres schema.

    json
    {
      "postgres_host": "localhost",
      "postgres_port": 5432,
      "postgres_database": "my_analytics",
      "postgres_username": "myuser",
      "postgres_password": "1234",
      "postgres_schema": "mytapname"
    }
  3. Run target-postgres against a Singer tap.

    bash
    ~/.virtualenvs/tap-something/bin/tap-something \
      | ~/.virtualenvs/target-postgres/bin/target-postgres \
        --config ~/singer.io/target_postgres_config.json >> state.json

    If you are running windows, the following is equivalent:

    venvs\tap-exchangeratesapi\Scripts\tap-exchangeratesapi.exe | ^
    venvs\target-postgresql\Scripts\target-postgres.exe ^
    --config target_postgres_config.json

Config.json

The fields available to be specified in the config file are specified here.

Field Type Default Details
postgres_host ["string", "null"] "localhost"
postgres_port ["integer", "null"] 5432
postgres_database ["string"] N/A
postgres_username ["string", "null"] N/A
postgres_password ["string", "null"] null
postgres_schema ["string", "null"] "public"
postgres_sslmode ["string", "null"] "prefer" Refer to the libpq docs for more information about SSL
postgres_sslcert ["string", "null"] "~/.postgresql/postgresql.crt" Only used if a SSL request w/ a client certificate is being made
postgres_sslkey ["string", "null"] "~/.postgresql/postgresql.key" Only used if a SSL request w/ a client certificate is being made
postgres_sslrootcert ["string", "null"] "~/.postgresql/root.crt" Used for authentication of a server SSL certificate
postgres_sslcrl ["string", "null"] "~/.postgresql/root.crl" Used for authentication of a server SSL certificate
invalid_records_detect ["boolean", "null"] true Include false in your config to disable target-postgres from crashing on invalid records
invalid_records_threshold ["integer", "null"] 0 Include a positive value n in your config to allow for target-postgres to encounter at most n invalid records per stream before giving up.
disable_collection ["string", "null"] false Include true in your config to disable Singer Usage Logging.
logging_level ["string", "null"] "INFO" The level for logging. Set to DEBUG to get things like queries executed, timing of those queries, etc. See Python's Logger Levels for information about valid values.
persist_empty_tables ["boolean", "null"] False Whether the Target should create tables which have no records present in Remote.
max_batch_rows ["integer", "null"] 200000 The maximum number of rows to buffer in memory before writing to the destination table in Postgres
max_buffer_size ["integer", "null"] 104857600 (100MB in bytes) The maximum number of bytes to buffer in memory before writing to the destination table in Postgres
batch_detection_threshold ["integer", "null"] 5000, or 1/40th max_batch_rows How often, in rows received, to count the buffered rows and bytes to check if a flush is necessary. There's a slight performance penalty to checking the buffered records count or bytesize, so this controls how often this is polled in order to mitigate the penalty. This value is usually not necessary to set as the default is dynamically adjusted to check reasonably often.
state_support ["boolean", "null"] True Whether the Target should emit STATE messages to stdout for further consumption. In t

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonetljson-schemapostgressinger

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库