DataLab Docs
  • What is DataLab?
  • Work
    • Creating a workbook
    • Sharing a workbook
    • Managing a workbook
    • Code cell
      • Working with packages
    • Text cell
      • Including images
    • SQL cell
      • SQL scenarios
      • Parameterize your SQL query
    • Explore Data cell
    • Chart cell
      • Configuring your chart
      • Pivot charts
      • Migration guide
    • AI Assistant
    • Version history
    • Scheduled runs
    • Hiding and showing cells
    • Long-running cells
    • Report view
    • Environment variables
    • Git and GitHub
  • Connect to Data
    • Connect your data to DataLab
    • Sharing a Data Source
    • Airtable
    • Amazon Athena
    • Amazon S3
    • Databricks
    • Dropbox
    • Files
    • Google Drive
    • Google BigQuery
    • Google Sheets
    • MariaDB
    • Microsoft SQL Server
    • MongoDB
    • MotherDuck
    • MySQL
    • Oracle Database
    • PostgreSQL
    • Redshift
    • Snowflake
    • Supabase
  • Guides
    • Publish a notebook
    • Importing data from flat files
    • Resizing plots
    • Show Bokeh and Pyvis plots
  • Resources
    • Pricing
    • Manage group settings
    • Reporting for Group Admins
    • DataLab for education
    • Technical requirements
    • Addressing slow code
    • Address R vulnerability
    • Get help
Powered by GitBook
On this page

Was this helpful?

  1. Connect to Data

Airtable

PreviousSharing a Data SourceNextAmazon Athena

Last updated 12 months ago

Was this helpful?

This article covers all the necessary steps to connect to Airtable and query Airtable data with Python from inside DataLab. These steps and the necessary sample code are also available in (click to create your own copy).

Setup

You need to take a couple of setup steps in Airtable and DataLab to set up a so-called personal access token that you can use to programmatically access data in Airtable.

  • Create an Airtable account if you haven't already .

  • Make sure your Airtable account contains a 'base' (a database). If you don't have data lying around, click "Start with templates" on your Airtable Homepage.

  • Create the personal access token:

    • Click on your avatar icon top right, and select "Developer Hub"

    • In the "Personal access tokens" tab, click "Create new token"

    • Specify a name for your token, e.g. 'DataLab Access'

    • Add a scope. data.records:read is enough if you want to fetch data from Airtable. If you also want to write back results of your calculations to Airtable, add data.records:write as well.

    • Add a base to access. You can select just one base or all current and future bases in your workbook. Make sure you at least select the base that you want to access from inside DataLab.

    • Click "Create token"

    • Copy the generated personal access token (PAT) to your clipboard for later use.

    • In the DataLab editor, open up the environment variables in the menu bar (Environment > Environment variables) and click on "Add".

    • Set Name to AIRTABLE_PAT

    • In Value paste the PAT that you copied to your clipboard in the previous step.

    • Set the "Environment Variable Set Name" to something meaningful, e.g. "Airtable PAT"

    • Click "Create", "Next" and finally, "Connect". Your workbook session will restart, and AIRTABLE_PAT will now be available as an environment variable in your workbook.

Securely store the PAT in DataLab as an :

If you've done all of the steps above successfully, you're now ready to run some Python code to connect to Airtable data! The code is available in ; you can click to create your own copy that you can edit to your use case.

environment variable
this workbook
this link
this workbook
this link
here
Create a Personal Access Token in Airtable
Store the Airtable PAT in DataLab as an environment variable