Created
March 22, 2021 20:58
-
-
Save johnmastro/e3b5e1fe4e55665967e679dffb1de116 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load(connection, airtable, table_name, field_info, destination): | |
restarts = 0 | |
while True: | |
try: | |
chunks = airtable.iter_chunks(table_name) | |
# Airtable will give us the records in chunks of 100, which is | |
# inefficiently small for loading into Snowflake, so buffer them up into | |
# chunks of a few thousand | |
chunks = rechunked(chunks, 5000) | |
return _load_chunks(connection, chunks, field_info, destination) | |
except AirtableIteratorError: | |
if restarts == 3: | |
raise | |
else: | |
restarts += 1 | |
log.warn( | |
"airtable list records iterator not available, restarting", | |
restart=restarts, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment