Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating a single value in Firebase with python

I am a total newbie when it comes to backend. I am working on a very simple webpage that needs one element to be updated every couple minutes or so. I'd like it to make a request to my Firebase database, get a single integer, and change a number on the webpage to that integer.

Right now I am having trouble updating the Firebase with a simple Python program. Here is what my Firebase looks like every time I run my python script: Click

When I run the script, it adds 6 new random variables with the value I'd like to send to Firebase. Here is what my code looks like so far:

from firebase import firebase
fb = firebase.FirebaseApplication('https://myAssignedDomain.com/', None)
Result = fb.post('test/coffee', {'percentage': 40})

What do I need to do in order to only change one existing value in Firebase rather than create 6 new random variables?

like image 824
WaterlessStraw Avatar asked May 10 '16 20:05

WaterlessStraw


People also ask

Which method is used to update the Firebase data?

4. Which method used to update the Firebase data? Explanation: We can update the Firebase data using update command. 5.

How do you increment value in Firebase Realtime Database?

There is no server-side way to increment values (or do other calculations) in the Firebase Database. Your approach is one way of doing this, but it has the chance of leading to a race condition. The result is now likely incorrect (it depends on your use-case).

How do I manually add data to Firebase?

If you open your app from Firebase dashboard, you can add data manually by clicking on the + sign. We will create a simple data structure.


1 Answers

This is how you can update the value of a particular property in firebase python 1.2 package

from firebase import firebase
fb = firebase.FirebaseApplication('https://myAssignedDomain.com/', None)
fb.put('test/asdf',"count",4) #"path","property_Name",property_Value
like image 103
ifti Avatar answered Oct 14 '22 14:10

ifti