I’ve been there, mate. Dealing with library version mismatches can be a real pain, especially when deploying code to different environments.
In your case, it seems you’re running an older version locally and a newer one online. This explains the method name changes you’ve noticed. For sorting in the newer versions, you’ll want to use the ‘sort’ parameter within the ‘get’ method, like this:
records = table.get(sort=[{‘field’: ‘YourFieldName’, ‘direction’: ‘desc’}])
If that doesn’t cut it, you might need to fall back on manual sorting after fetching the records. It’s not ideal, but it gets the job done:
records = table.get()
sorted_records = sorted(records, key=lambda x: x[‘fields’][‘YourFieldName’], reverse=True)
To avoid these headaches in the future, I’d strongly recommend using virtual environments and a requirements.txt file to keep your dependencies consistent across all platforms. It’s saved me countless hours of debugging similar issues.
I’ve encountered similar issues when working with the Airtable Python library across different environments. It sounds like you might be dealing with different versions of the library. The changes you’ve noticed (insert to create, get_all to get) suggest you’re using an older version locally and a newer one online.
For sorting, in newer versions, you typically use the ‘sort’ parameter within the ‘get’ method. Try something like this:
records = table.get(sort=[‘FieldName’])
If that doesn’t work, you might need to sort the results manually after fetching them. You could use Python’s built-in sorting capabilities on the returned list of records.
I’d recommend checking the library versions in both environments and trying to align them. This should resolve most of the discrepancies you’re experiencing.