python firebase realtime listener

前端 未结 6 1082
离开以前
离开以前 2020-12-05 16:47

Hi there I\'m new in python. I would like to implement the listener on my Firebase DB. When I change one or more parameters on the DB my Python code have to do something. Ho

6条回答
  •  死守一世寂寞
    2020-12-05 17:20

    It looks like this is supported now (october 2018): although it's not documented in the 'Retrieving Data' guide, you can find the needed functionality in the API reference. I tested it and it works like this:

    def listener(event):
        print(event.event_type)  # can be 'put' or 'patch'
        print(event.path)  # relative to the reference, it seems
        print(event.data)  # new data at /reference/event.path. None if deleted
    
    firebase_admin.db.reference('my/data/path').listen(listener)
    

提交回复
热议问题