Skip to main content

Overview

This guide walks through how to leverage the gluestick to_singer function to include typing information in payloads sent to your target, and how to send primary key(s) which can be useful when pushing to databases.

Setup your environment

Dependencies

The script we will walk through is tested with the following requirements.txt – if you have different behavior, verify your dependency versions match.

Verify your gluestick version

Ensure that the gluestick library version is 1.0.9 or greater or the to_singer function will not be available!
requirements.txt

Sample data

For this example we will be working with some testing Shopify products data. Download the CSV here to follow along.
products.csv

Sample Script

Typing with pandas

First you will need to ensure your pandas dataframe has the correct types when the data is exported to the target. This is generally achieved using the astype function Refer to the sample script below which:
  • Reads the products CSV as pandas dataframe,
  • Does some light transformation on the data, and
  • Casts the types of the columns in the dataframe
etl.py

Export the data

Now that your dataframe has the types set, we can export the data using the gluestick to_singer function. The arguments of the to_singer function are: Refer to the sample script below:
etl.py
This generates the following output (download here)
data.singer