how can I get the firebase database data in a nested location using python? -


i have database structure

enter image description here

each business id has inventory, in inventory, there many items , each item has many attributes name, part number , nsn. need nsns each inventory item array tried code , other variations of it

db = firebase.database()  businesses = db.child("businesses").get() user in businesses.each(): userid = user.key() inventorydb = db.child("businesses").child(userid).child("inventory").get()   #looping through inventory child  item in inventorydb.each():     itemid = item.key()     itemdb = db.child("businesses").child(userid).child("inventory").child(itemid).get() print(itemdb.val("nsn")) 

but keep getting error

val() takes 1 positional argument 2 given 

how can nsns each inventory item?

well, looking @ documentation, val() function returns dictionary of snapshot

you want

print(itemdb.val()["nsn"]) 

i recommend rewriting firebase structure "avoid building nests"


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -