gtalarico / pyairtable

Python Api Client for Airtable
https://pyairtable.readthedocs.io
MIT License
786 stars 139 forks source link

Issue with table.update() #146

Closed nickg-52 closed 2 years ago

nickg-52 commented 2 years ago

Can someone help to address the issue around updating a table field value using table.update():

Code Attempt 1: Table.update('recELQAmelax4291X', {"Hours Used": 40})

TypeError Traceback (most recent call last)

in 1 ## Update a record in the Projects Table ## 2 ----> 3 Table.update('recELQAmelax4291X', {"Hours Used": 40}) 4 5 # Table.update([{record_id = "recELQAmelax4291X", fields={"Hours Used": 21}}]) TypeError: update() missing 1 required positional argument: 'fields' --------------------------------------------------------------------------- **Code Attempt 2:** ` Table.update({id:'recELQAmelax4291X', fields:{"Hours Used": 40}}) ` --------------------------------------------------------------------------- NameError Traceback (most recent call last) in 3 # Table.update('recELQAmelax4291X', {"Hours Used": 40}) 4 ----> 5 Table.update({id:'recELQAmelax4291X', fields:{"Hours Used": 40}}) NameError: name 'fields' is not defined
gtalarico commented 2 years ago

See docs here. https://pyairtable.readthedocs.io/en/latest/api.html#updating-records

Should be: table.update('id', { 'col': 'value'})

wanghaisheng commented 2 years ago

@gtalarico for update we need id first how to exact get id from filed value lets say a id or name filed