FireO
FireO copied to clipboard
Connect From Google Colab Notebook
Hi,
I'm testing out here a Google Colab (https://colab.research.google.com/) and wanted to connect to Firebase using your ORM library. Can you please correct my code and see what I'm doing wrong, I'm just trying to connect using a service account.
!pip install fireo
from fireo.models import Model
from fireo.fields import TextField
from fireo.database import connection
connection(from_file="crendentials.json")
This is the error I get on the connection line:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/fireo/database/database.py in connect(self, credentials, from_file)
41 elif from_file:
---> 42 self._conn = firestore.Client.from_service_account_json(from_file)
43 else:
/usr/local/lib/python3.6/dist-packages/google/cloud/client.py in from_service_account_json(cls, json_credentials_path, *args, **kwargs)
85 kwargs["credentials"] = credentials
---> 86 return cls(*args, **kwargs)
87
/usr/local/lib/python3.6/dist-packages/google/cloud/firestore_v1/client.py in __init__(self, project, credentials, database, client_info, client_options)
109 super(Client, self).__init__(
--> 110 project=project, credentials=credentials, _http=None
111 )
/usr/local/lib/python3.6/dist-packages/google/cloud/client.py in __init__(self, project, credentials, client_options, _http)
249 _ClientProjectMixin.__init__(self, project=project)
--> 250 Client.__init__(self, credentials=credentials, client_options=client_options, _http=_http)
/usr/local/lib/python3.6/dist-packages/google/cloud/client.py in __init__(self, credentials, _http, client_options)
135
--> 136 if credentials and client_options.credentials_file:
137 raise google.api_core.exceptions.DuplicateCredentialArgs(
AttributeError: 'ClientOptions' object has no attribute 'credentials_file'
The above exception was the direct cause of the following exception:
DBConnectionError Traceback (most recent call last)
<ipython-input-64-6a1afad9d26a> in <module>()
----> 1 connection(from_file="cred/infnet-f3892-firebase-adminsdk-ku8cj-d30235d835.json")
/usr/local/lib/python3.6/dist-packages/fireo/database/database.py in connect(self, credentials, from_file)
44 raise DBConnectionError("Credentials or service account json file required to connect with firestore")
45 except Exception as e:
---> 46 raise DBConnectionError(e) from e
47
48 @property
DBConnectionError: 'ClientOptions' object has no attribute 'credentials_file'
Don't know about colab notebook but this is working fine in system. Might be there is some problem in loading "credentials.json" file into colab. From where it is getting the "credentials.json" file ?