A Singer.io Target for Postgres
A Singer postgres target, for use with Singer streams generated by Singer taps.
version and ACTIVATE_VERSION messages.libpq dependency# macos
brew install postgresql# ubuntu
sudo apt install libpq-devsinger-target-postgrespip install singer-target-postgresFollow the
Singer.io Best Practices
for setting up separate tap and target virtualenvs to avoid version
conflicts.
Create a config file at
~/singer.io/target_postgres_config.json with postgres connection
information and target postgres schema.
{
"postgres_host": "localhost",
"postgres_port": 5432,
"postgres_database": "my_analytics",
"postgres_username": "myuser",
"postgres_password": "1234",
"postgres_schema": "mytapname"
}Run target-postgres against a Singer tap.
~/.virtualenvs/tap-something/bin/tap-something \
| ~/.virtualenvs/target-postgres/bin/target-postgres \
--config ~/singer.io/target_postgres_config.json >> state.jsonIf 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.jsonThe 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 |
No open issues yet, or sync has not completed.