简体   繁体   中英

Is there a way to listen for firebase database changes in python?

I have a python application that listens for put(add) events in my firebase database using Pyrebase but the stream feature of pyrebase is deprecated and stops listening after 30 minutes. The library is not supported anymore.

I figured out that firebase has a library for python called firebase-admin, however this does not have a streaming/listener capability for python, only for java. Is there any other way to do this?

#  get database instance
conn_instance = Database()
db = conn_instance.get_database()
storage = conn_instance.get_storage()
main_queue = Queue()


def stream_handler(message):
    # Reads stream input 
    print(message)

# Stream is created to firebase database using Pyrebase
request_stream = db.child("requests").stream(stream_handler)  

def close_application():
    #  Closes stream 
    request_stream.close()

I would like to have firebase database listener functionality for python as this is needed to process new database inputs.

Firebase-Admin was the answer it works like a charm and is really not so hard to convert to from pyrebase.

basically i just replaced ".stream" with ".listen" and had to change how this "Event" was processed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM