-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firestore: Cannot get Quickstart to work #794
Comments
@sandroboehme Can you please provide the full Python traceback? Also, what version of the |
Thanks for having a look into that @tseaver. That's much appreciated as I would rather like to use the client lib then the REST interface I'm using now! Here is the full traceback:
I've pushed my example into this repo: |
The error descriptions you are reporting ( $ ping firestore.googleapis.com |
It does resolve to an IP address at the host where the application is running. But there is a CNAME to
|
I could solve it by setting |
+1
import typing as _T
import logging as _logging
import os as _os
from google.cloud import firestore_v1 as _firestore
from google.cloud.firestore_v1.base_document import (
BaseDocumentReference as _BaseDocumentReference,
)
from .. import exceptions as _exceptions
_os.environ['GRPC_DNS_RESOLVER'] = 'native'
_logger = _logging.getLogger(__name__)
class Collection:
def __init__(self,
name:str,
client: _firestore.Client,
):
self.name = name
self._client = client
self._collection = self._client.collection(name)
def insert_one(self, document: dict) -> _T.Tuple[int, _BaseDocumentReference]:
span.set_attribute('self.name', self.name)
span.set_attribute('self._client', repr(self._client))
span.set_attribute('self._collection', repr(self._collection))
timestamp, document_ref = self._collection.add(document)
return timestamp, document_ref.get()
def get(self, id: str):
document_ref = self._collection.document(id)
document = document_ref.get()
if document.exists:
return document
raise _exceptions.RecordNotFoundError(id)
class Database:
def __init__(self, client: _firestore.Client):
self._client = client
def __getattr__(self, name) -> Collection:
return Collection(name, self._client)
def __getitem__(self, name):
return self.__getattr__(name)
class Client:
_databases = {}
def __init__(
self,
credential=None,
**options
):
self.options = options
self._credential = credential
@property
def default_db(self):
return self.__getdatabase('Root')
def __getdatabase(self, name) -> Database:
_logger.info(self._databases)
try:
return self._databases[name]
except KeyError:
client = _firestore.Client(
credentials=self._credential,
client_options=self.options,
)
self._databases[name] = Database(client)
return self._databases[name]
except Exception as e:
raise e
def __getattr__(self, name):
return self.__getdatabase(name)
def __getitem__(self, name):
return self.__getattr__(name)
|
just happened to me, setting environ did not solve it |
solved it by not using firestore, and using realtime db instead xD |
Closing as this is an old issue, which I don't believe is currently impacting anyone. If anyone is still seeing this issue, let me know and I'll try to reproduce |
I followed the quickstart guide for Firestore in Python but I couldn't get it to run as I got this error message:
This is my code:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
for authenticationgoogle-cloud-firestore
is installed in a new virtualenv as described in the quickstart guide.gcloud
project with:gcloud config set project example4
python --version
returnsPython 3.7.1
There must me something simple missing. Any hints are appreciated!
The text was updated successfully, but these errors were encountered: