Airtable Foreign Data Wrapper
Installation
Requirements
PostgreSQL 9.1+ with Multicorn extension installed.
Loading extension and defining FDW server
Ensure multicorn is loaded and define Foreign Data Wrapper for airtable
create extension if not exists multicorn;
create server if not exists multicorn_airtable_srv foreign data wrapper multicorn options (
wrapper 'airtable_fdw.AirtableFDW'
);
Usage
Define table as
create foreign table schema.table_name (
"_id" varchar options (rowid 'true'), -- column used as rowid, may be any name,
-- should appear only onece
"Some text column" varchar,
"Some numeric column" numeric,
"Some date column" date,
"Some complex column" json, -- can be used for complex fields but see example below
"Some json nullable column" json options (nulljson 'true'), -- keep nulls as json ('null'::json instead of null::json)
"Some computed column" varchar options (computed 'true') -- column that won't be modified with update
-- may appear multiple times
) server multicorn_airtable_srv options (
api_key '...', -- api access key
base_key '...', -- database identifier
table_name '...', -- name of table to read from
view_name '...', -- optional view name, if not present raw table will be read
rowid_column '...' -- optional rowid column name will be used if no column has `rowid` option set
);
If complex column - like Collaborator - appears in table it is read from AirTable API as a json and could be treated as json or as a complex, custom defined type.
create type AirtableCollaborator as
(
id varchar,
email varchar,
"name" varchar
);
create foreign table schema.table_name (
"_id" varchar options (rowid 'true'),
"editor" AirtableCollaborator options (complextype_fields 'id,email,name', complextype_send 'email')
) server multicorn_airtable_srv options (
api_key '...',
base_key '...',
table_name '...'
);
where:
complextype_fields 'id,email,name'indicates how record string should be constructed fromjson- so{"id": "someid", "email": "me@example.com", "name":"My Name"}will be converted to(someid,me@example.com,My Name)and will be correctly casted toAirtableCollaboratortype.complextype_send 'email'means that when this field is modified onlyemailfield will be sent to API
Usage Tips
- Use
ANDinWHEREclause whenever possible,ORs are not handled well (at all?) by multicorn so unconditional queries are sent to Airtable (watch the quota!). - If
ORis required try to replace it withIN (...)
Features
- Configurable to read from given base / table / view
- SQL
WHEREclause transformed toformulaquery (so number of requests to API is optimized) - Batch
INSERT/UPDATE/DELETE - support for complex types - json is parsed to complex type on read (
SELECT), and single, selected field is set on write (INSERT,UPDATE)
Metadata
Release files for airtable-fdw 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| airtable_fdw-0.3.4.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| airtable_fdw-0.3.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / airtable_fdw-0.3.4.tar.gz
| Download URL | airtable_fdw-0.3.4.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83b3fe271936b89b4435d58086c8caf8010d31db361cbc2f2543adc496066b59
|
|
BLAKE2b-256 checksum How to use checksums |
46ff08852477c3f7fc07b33f94da99baf28a8c7b6fd603c74740ef0f2ff2c660
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.7.12 Linux/5.11.0-1028-azure
|
Release files / airtable_fdw-0.3.4-py3-none-any.whl
| Download URL | airtable_fdw-0.3.4-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
112df48009a8f1c9d22cacdf333df72aa1cff6cc9865fa9fa9298c92c41ff332
|
|
BLAKE2b-256 checksum How to use checksums |
b7dc774efb3590f0bf35995389c895c58825802f013d1aff38b051d6d82bea00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.7.12 Linux/5.11.0-1028-azure
|