How to Build an ETL App for Linear Data in Python with CData

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Create ETL applications and real-time data pipelines for Linear data in Python with petl.

The rich ecosystem of Python modules lets you get to work quickly and integrate your systems more effectively. With the CData Python Connector for Linear and the petl framework, you can build Linear-connected applications and pipelines for extracting, transforming, and loading Linear data. This article shows how to connect to Linear with the CData Python Connector and use petl and pandas to extract, transform, and load Linear data.

With built-in, optimized data processing, the CData Python Connector offers unmatched performance for interacting with live Linear data in Python. When you issue complex SQL queries from Linear, the driver pushes supported SQL operations, like filters and aggregations, directly to Linear and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations).

Connecting to Linear Data

Connecting to Linear data looks just like connecting to any relational data source. Create a connection string using the required connection properties. For this article, you will pass the connection string as a parameter to the create_engine function.

You can authenticate to Linear with a personal API key or with OAuth 2.0. The API key is the simplest option for connecting with your own Linear account.

Authenticating with an API Key

Set the following connection properties:

  • AuthScheme: Set this to APIKey.
  • APIKey: A Linear personal API key.

To create a personal API key, log in to Linear, open Settings > Security & access > Personal API keys, select New API key, and create it. Copy the key immediately, because Linear shows it only once.

Authenticating with OAuth

OAuth requires a custom OAuth application registered in Linear (Settings > API > OAuth applications), which provides the OAuthClientId and OAuthClientSecret. Two flows are supported:

  • Authorization code: Set AuthScheme to OAuth, InitiateOAuth to GETANDREFRESH, and provide OAuthClientId, OAuthClientSecret, and the CallbackURL defined in your application (e.g., http://localhost:33333). The driver opens Linear in your browser so you can grant access.
  • Client credentials: Set AuthScheme to OAuthClient and provide OAuthClientId and OAuthClientSecret. This authenticates the application itself, with no browser interaction, and suits machine-to-machine integrations.

By default, the driver requests the read,write scopes. The driver refreshes the access token automatically when it expires.

After installing the CData Linear Connector, follow the procedure below to install the other required modules and start accessing Linear through Python objects.

Install Required Modules

Use the pip utility to install the required modules and frameworks:

pip install petl
pip install pandas

Build an ETL App for Linear Data in Python

Once the required modules and frameworks are installed, we are ready to build our ETL app. Code snippets follow, but the full source code is available at the end of the article.

First, be sure to import the modules (including the CData Connector) with the following:

import petl as etl
import pandas as pd
import cdata.linear as mod

You can now connect with a connection string. Use the connect function for the CData Linear Connector to create a connection for working with Linear data.

cnxn = mod.connect("AuthScheme=APIKey;APIKey=myAPIKey;")

Create a SQL Statement to Query Linear

Use SQL to create a statement for querying Linear. In this article, we read data from the Team entity.

sql = "SELECT id, name FROM Team WHERE key = 'ENG'"

Extract, Transform, and Load the Linear Data

With the query results stored in a DataFrame, we can use petl to extract, transform, and load the Linear data. In this example, we extract Linear data, sort the data by the name column, and load the data into a CSV file.

Loading Linear Data into a CSV File

table1 = etl.fromdb(cnxn,sql)

table2 = etl.sort(table1,'name')

etl.tocsv(table2,'team_data.csv')

With the CData Python Connector for Linear, you can work with Linear data just like you would with any database, including direct access to data in ETL packages like petl.

Free Trial & More Information

Download a free, 30-day trial of the CData Python Connector for Linear to start building Python apps and scripts with connectivity to Linear data. Reach out to our Support Team if you have any questions.



Full Source Code


import petl as etl
import pandas as pd
import cdata.linear as mod

cnxn = mod.connect("AuthScheme=APIKey;APIKey=myAPIKey;")

sql = "SELECT id, name FROM Team WHERE key = 'ENG'"

table1 = etl.fromdb(cnxn,sql)

table2 = etl.sort(table1,'name')

etl.tocsv(table2,'team_data.csv')

Ready to get started?

Download a free trial of the Linear Connector to get started:

 Download Now

Learn more:

Linear Icon Linear Python Connector

Python Connector Libraries for Linear Data Connectivity. Integrate Linear with popular Python tools like Pandas, SQLAlchemy, Dash & petl.