Google News
logo
TinyDB - Interview Questions
Can you describe the syntax for updating data in a TinyDB database using the update() method? Give an example.
The update() method is used to update data in a TinyDB database. It takes two arguments, the first is a Python dictionary representing the update criteria, and the second is a Python dictionary representing the new values.

Example :
from tinydb import TinyDB, Query
db = TinyDB(‘path/to/database.json’)
table = db.table(‘mytable’)
User = Query() table.update({‘name’: ‘Jane Doe’}, User.name == ‘John Doe’)?
Advertisement