Utilities

New in version 1.0.0.

pyairtable.utils.attachment(url, filename='')[source]

Returns a dictionary using the expected dicitonary format for attachments.

When creating an attachment, url is required, and filename is optional. Airtable will download the file at the given url and keep its own copy of it. All other attachment object properties will be generated server-side soon afterward.

Note

Attachment field values muest be an array of objects.

Usage:
>>> table = Table(...)
>>> profile_url = "https://myprofile.com/id/profile.jpg
>>> rec = table.create({"Profile Photo": [attachment(profile_url)]})
{
    'id': 'recZXOZ5gT9vVGHfL',
    'fields': {
        'attachment': [
            {
                'id': 'attu6kbaST3wUuNTA',
                'url': 'https://aws1.discourse-cdn.com/airtable/original/2X/4/411e4fac00df06a5e316a0585a831549e11d0705.png',
                'filename': '411e4fac00df06a5e316a0585a831549e11d0705.png'
            }
        ]
    },
    'createdTime': '2021-08-21T22:28:36.000Z'
}
Return type

dict

pyairtable.utils.date_from_iso_str(value)[source]

Converts ISO 8601 date string into a date object. Expected format is “2014-09-05”

Parameters

value (str) – date string e.g. “2014-09-05”

Return type

date

pyairtable.utils.date_to_iso_str(value)[source]

Converts date or datetime object into Airtable compatible ISO 8601 string e.g. “2014-09-05”

Parameters

value (Union[date, datetime]) – date or datetime object

Return type

str

pyairtable.utils.datetime_from_iso_str(value)[source]

Converts ISO 8601 datetime string into a datetime object. Expected format is “2014-09-05T07:00:00.000Z”

Parameters

value (str) – datetime string e.g. “2014-09-05T07:00:00.000Z”

Return type

datetime

pyairtable.utils.datetime_to_iso_str(value)[source]

Converts datetime object into Airtable compatible ISO 8601 string e.g. “2014-09-05T12:34:56.000Z”

Parameters

value (datetime) – datetime object

Return type

str