尝试使用Python检索数据时出现以下错误。我想要检索它时得到以下stacktrace。还请告诉我如何使用python代码存储这些数据。目前我没有代码存储。
Traceback (most recent call last):
File "data.py", line 3, in <module>
result = firebase.get('/varnika-c226a', None)
File "/home/varnika/Downloads/python-firebase-master/firebase/decorators.py", line 19, in wrapped
return f(*args, **kwargs)
File "/home/varnika/Downloads/python-firebase-master/firebase/firebase.py", line 274, in get
return make_get_request(endpoint, params, headers, connection=connection)
File "/home/varnika/Downloads/python-firebase-master/firebase/decorators.py", line 19, in wrapped
return f(*args, **kwargs)
File "/home/varnika/Downloads/python-firebase-master/firebase/firebase.py", line 38, in make_get_request
response = connection.get(url, params=params, headers=headers, timeout=timeout)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/adapters.py", line 502, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='varnika-c226a.firebaseio.com', port=443): Max retries exceeded with url: /varnika-c226a/.json (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 302 Found',)))
varnika@varnika-Inspiron-N5110:~/Downloads/python-firebase-master$ python data.py
Traceback (most recent call last):
File "data.py", line 4, in <module>
result = firebase.get('/varnika-c226a', None)
File "/home/varnika/Downloads/python-firebase-master/firebase/decorators.py", line 19, in wrapped
return f(*args, **kwargs)
File "/home/varnika/Downloads/python-firebase-master/firebase/firebase.py", line 274, in get
return make_get_request(endpoint, params, headers, connection=connection)
File "/home/varnika/Downloads/python-firebase-master/firebase/decorators.py", line 19, in wrapped
return f(*args, **kwargs)
File "/home/varnika/Downloads/python-firebase-master/firebase/firebase.py", line 38, in make_get_request
response = connection.get(url, params=params, headers=headers, timeout=timeout)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/home/varnika/miniconda2/lib/python2.7/site-packages/requests/adapters.py", line 502, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='varnika-c226a.firebaseio.com', port=443): Max retries exceeded with url: /varnika-c226a/.json (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 302 Found',)))
我正在使用的代码是:
from firebase import firebase
firebase = firebase.FirebaseApplication('https://varnika-c226a.firebaseio.com/', None)
result = firebase.get('/varnika-c226a', None)
print result
print firebase
答案 0 :(得分:0)
看起来这里有一些错误。您上面的那个与您无法连接到您的firebase实例有关,如下所述:
requests.exceptions.ProxyError: HTTPSConnectionPool(host='varnika-c226a.firebaseio.com', port=443): Max retries exceeded with url: /varnika-c226a/.json (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 302 Found',)))
第二个问题是,您似乎无法确定如何在firebase中存储数据。这很重要,因为当您在'/varnika-c226a'
中检索数据时,无法确定数据是否为result = firebase.get('/varnika-c226a', None)
。
希望这有帮助!