Feb-04-2021, 08:09 PM
hi
I am trying to save a dictionary named Dict on a .json file using TinyDB. The rest of the program is working except the part wherein the Dict is saved into the json file and then retrieved when the program is relaunched.
I tried to do something but got a TypeError instead.
this is the STARTING end of the program
TypeError: 'TinyDB' object is not subscriptable
I would be attaching the .py file also if anybody is interested.
pls forgive me for bad quality of code. i'm just a student
the code is in the file PHONEBOOK-1.py
https://drive.google.com/drive/folders/1...sp=sharing
pls reply to me if u need more information
I am trying to save a dictionary named Dict on a .json file using TinyDB. The rest of the program is working except the part wherein the Dict is saved into the json file and then retrieved when the program is relaunched.
I tried to do something but got a TypeError instead.
this is the STARTING end of the program
from tinydb import TinyDB,Query DB=TinyDB('DB.json') password='adis1999' #------Authenticator function--------- def authenticator(): input_pwd=input('Enter Password:') if input_pwd==password: print('Access Granted!\n') global Dict Dict=DB['_default'] menu() else: print('Wrong Password!\n') authenticator()and this is the ENDING end of the program:
print('Program Terminated!') DB['_default']=Dictand finally this is the ERROR message:
TypeError: 'TinyDB' object is not subscriptable
I would be attaching the .py file also if anybody is interested.
pls forgive me for bad quality of code. i'm just a student

the code is in the file PHONEBOOK-1.py
https://drive.google.com/drive/folders/1...sp=sharing
pls reply to me if u need more information