PipelineWise Singer Python Library

2.0.1 · maintenance · verified Sat Apr 11

This library is a fork of Singer's singer-python, specifically tailored for PipelineWise compatibility. It provides utilities for implementing the Singer.io data replication specification, enabling taps (data extractors) and targets (data loaders) to communicate using a standard JSON-based message format over stdout. The current version is 2.0.1, with releases occurring infrequently, typically driven by critical bug fixes or significant feature enhancements like performance improvements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic usage of the `pipelinewise-singer-python` library to emit Singer.io compliant messages (schema, record, state) to standard output. These messages can then be consumed by a Singer.io target. The example defines a simple schema and writes three records, followed by a state message.

import singer
import sys
import json

# Define a simple schema for demonstration
schema = {
    'properties': {
        'id': {'type': 'integer', 'key': True},
        'name': {'type': 'string'},
        'value': {'type': 'number'}
    }
}

# Write the schema message
singer.write_schema('my_stream', schema, ['id'])

# Write some record messages
records = [
    {'id': 1, 'name': 'Item A', 'value': 100.5},
    {'id': 2, 'name': 'Item B', 'value': 200.0},
    {'id': 3, 'name': 'Item C', 'value': 150.75}
]

for record in records:
    singer.write_record('my_stream', record)

# Write a state message (optional, but good practice for incremental processing)
singer.write_state({'last_processed_id': records[-1]['id']})

print("\n--- Output captured (simulated stdout) ---")
# For demonstration, manually capture output to show what 'singer' writes
# In a real Singer pipeline, this output goes to stdout.

view raw JSON →