Is there a way where you can actively have a listener for a Firebase Database in Python?
For instance, I have a node user
in the database, I want to be able to actively listen for any changes that immediately happens for a user and immediately make changes on it.
For now, I'm just using a for-loop. In my case, I have something like sync_state
for user with the integer value 3
. It gets changed to 4
when the session has been ended, I want to update value for that user.
Right now, I run the for-loop periodically, but it won't be efficient in the future when I have a lot of users in my database. Is there a way to do this in a python-ish way than using Node.JS?
You can use Firebase's REST Streaming API: https://firebase.google.com/docs/database/rest/retrieve-data#section-rest-streaming.
The blog post that introduced that API, includes some samples for Python: https://firebase.googleblog.com/2014/03/announcing-streaming-for-firebase-rest.html
There are some Python libraries that wrap that API: https://www.google.nl/webhp#q=firebsae%20python%20streaming
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With