擅长:python、mysql、java
<p>我在<strong>流处理程序中也会遇到错误,因此我使用了<strong>pyrbase</strong><br/>
希望它也适用于你</p>
<p>尝试使用pyrebase</p>
<pre><code>pip install Pyrebase
</code></pre>
<p>如果在安装时遇到版本错误,请尝试此操作</p>
<pre><code>pip3 install pyrebase4
</code></pre>
<p>来自<a href="https://github.com/nhorvath/Pyrebase4" rel="nofollow noreferrer">github, click for more.</a>的资源</p>
<p>然后试试这个代码</p>
<pre><code>import pyrebase
config = {
"apiKey": "apiKey",
"authDomain": "projectId.firebaseapp.com",
"databaseURL": "https://databaseName.firebaseio.com",
"storageBucket": "projectId.appspot.com"
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
def stream_handler(message):
print(message["event"]) # put
print(message["path"]) # /-K7yGTTEp7O549EzTYtI
print(message["data"]) # {'title': 'Pyrebase', "body": "etc..."}
my_stream = db.child("users").stream(stream_handler)
</code></pre>
<p>如果firebase live数据库中发生任何更改,将运行<code>stream_handler</code></p>