Package: airtable-export
airtable-exportExport Airtable data to files on diskInstallationInstall this tool usingpip:$ pip install airtable-exportUsageYou will need to know the following information:Your Airtable base ID - this is a string starting withapp...Your Airtable API key - this is a string starting withkey...The names of each of the tables that you wish to exportYou can export all of your data to a folder calledexport/by running the following:airtable-export export base_id table1 table2 --key=keyThis example would create two files:export/table1.ymlandexport/table2.yml.Rather than passing the API key using the--keyoption you can set it as an environment variable calledAIRTABLE_KEY.Export optionsBy default the tool exports your data as YAML.You can also export as JSON or asnewline delimited JSONusing the--jsonor--ndjsonoptions:airtable-export export base_id table1 table2 --key=key --ndjsonYou can pass multiple format options at once. This command will create a.json,.ymland.ndjsonfile for each exported table:airtable-export export base_id table1 table2 \
    --key=key --ndjson --yaml --jsonSQLite database exportYou can export tables to a SQLite database file using the--sqlite database.dboption:airtable-export export base_id table1 table2 \
    --key=key --sqlite database.dbThis can be combined with other format options. If you only specify--sqlitethe export directory argument will be ignored.The SQLite database will have a table created for each table you export. Those tables will have a primary key column calledairtable_id.If you run this command against an existing SQLite database records with matching primary keys will be over-written by new records from the export.Request optionsBy default the tool usespython-httpx's default configurations.You can override theuser-agentusing the--user-agentoption:airtable-export export base_id table1 table2 --key=key --user-agent "Airtable Export Robot"You can override thetimeout during a network read operationusing the--http-read-timeoutoption. If not set, this defaults to 5s.airtable-export export base_id table1 table2 --key=key --http-read-timeout 60Running this using GitHub ActionsGitHub Actionsis GitHub's workflow automation product. You can use it to runairtable-exportin order to back up your Airtable data to a GitHub repository. Doing this gives you a visible commit history of changes you make to your Airtable data - likethis one.To run this for your own Airtable database you'll first need to add the following secrets to your GitHub repository:AIRTABLE_BASE_IDThe base ID, a string beginning `app...`AIRTABLE_KEYYour Airtable API keyAIRTABLE_TABLESA space separated list of the Airtable tables that you want to backup. If any of these contain spaces you will need to enclose them in single quotes, e.g. 'My table with spaces in the name' OtherTableWithNoSpacesOnce you have set those secrets, add the following as a file called.github/workflows/backup-airtable.yml:name:Backup Airtableon:workflow_dispatch:schedule:-cron:'320***'jobs:build:runs-on:ubuntu-lateststeps:-name:Check out repouses:actions/checkout@v2-name:Set up Pythonuses:actions/setup-python@v2with:python-version:3.8-uses:actions/cache@v2name:Configure pip cachingwith:path:~/.cache/pipkey:${{ runner.os }}-pip-restore-keys:|${{ runner.os }}-pip--name:Install airtable-exportrun:|pip install airtable-export-name:Backup Airtable to backups/env:AIRTABLE_BASE_ID:${{ secrets.AIRTABLE_BASE_ID }}AIRTABLE_KEY:${{ secrets.AIRTABLE_KEY }}AIRTABLE_TABLES:${{ secrets.AIRTABLE_TABLES }}run:|-airtable-export backups $AIRTABLE_BASE_ID $AIRTABLE_TABLES -v-name:Commit and push if it changedrun:|-git config user.name "Automated"git config user.email "actions@users.noreply.github.com"git add -Atimestamp=$(date -u)git commit -m "Latest data: ${timestamp}" || exit 0git pushThis will run once a day (at 32 minutes past midnight UTC) and will also run if you manually click the "Run workflow" button, seeGitHub Actions: Manual triggers with workflow_dispatch.DevelopmentTo contribute to this tool, first checkout the code. Then create a new virtual environment:cd airtable-export
python -mvenv venv
source venv/bin/activateOr if you are usingpipenv:pipenv shellNow install the dependencies and tests:pip install -e '.[test]'To run the tests:pytest