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, andfilename
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
ordatetime
object into Airtable compatible ISO 8601 string e.g. “2014-09-05”- Parameters
value (
Union
[date
,datetime
]) – date or datetime object- Return type
str