Skip to main content

Python DB-API and SQLAlchemy interface for Airtable.

Project description

airtable-db-api PyPI version main workflow codecov

A Python DB API 2.0 for Airtable

This module allows you to query Airtable using SQL. It exposes:

SQLAlchemy support

This module provides a SQLAlchemy dialect.

from sqlalchemy.engine import create_engine

engine = create_engine(
    'airtable://:keyXXXX@appYYY?peek_rows=10&tables=tableA&tables=tableB',
    date_columns={"tableA": ["My Date Field"]},
)

Metadata

At various points we need to know:

  1. The list of Tables supported in the Base
  2. The list of columns (Fields) supported on a given Table
  3. The type information for each Field

As of now we solve 1) by passing in a list of Tables using the tables query parameter on the URL. We solve 2) and 3) using some combination of the peek_rows query parameter specifying the number of rows to fetch from Airtable to guess Field types and a date_columns engine parameter to specify which columns should be parsed as Dates.

Alternatively, 1-3 could all be solved with a comprehensive base_metadata engine parameter that specifies the Tables and Fields. There are a number of ways to generate this, but one approach is scraping the Base's API docs page using a technique like this.

Further options are documented here

Installation

I was having issues with apsw-3.9.2.post1 (the newest version of apsw that would install for me from PyPI) and ended up needing to follow the instructions here to build / install apsw from source. There is an open ticket on the APSW project to provide newer wheels. The issue might be triggered if the table name needs escaping and the error looked like:

SystemError: <method 'execute' of 'apsw.Cursor' objects> returned NULL without setting an exception

Development

Python

$ pip install -r requirements-dev.txt

pre-commit

$ pre-commit install

black

Can be run manually as:

black --target-version py37

Roadmap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy-airtable-0.0.1.dev1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

sqlalchemy_airtable-0.0.1.dev1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy-airtable-0.0.1.dev1.tar.gz.

File metadata

File hashes

Hashes for sqlalchemy-airtable-0.0.1.dev1.tar.gz
Algorithm Hash digest
SHA256 62a0793f00e952cdf2899eeefe6ec370490210970806e0d4e762e76012d86a1a
MD5 758c63e730f5bda0570e6d977d4383b0
BLAKE2b-256 5ef4984ebb00f6bcc6769d75c0af50c8f4154ab99f7f6aa9170230f08c4100c4

See more details on using hashes here.

File details

Details for the file sqlalchemy_airtable-0.0.1.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_airtable-0.0.1.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bb40d778ef2f5b698ec05d647459bb935a9a1e0fc04b677069a190c702c9108
MD5 cc61c0f1d27b62fcb72547497b0768b2
BLAKE2b-256 29c736394fbbeb65bbd3230b936ae9f2d337acc37dedd9ddc9daac01a6597a01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page