Thiago Nascimento
Thiago Nascimento

Reputation: 1155

Firebase admin firestore error: 'Query' object has no attribute 'stream'

I'm unable to query a firebase firestore database from the python admin sdk.

Right now I'm trying to query using stream like the docs say:

db.collection('myDatabase').where(
    'ticker', '==', variable['ticker']).where(
    'type', '==', variable['type']).stream()

When I run this code I get the following error: 'Query' object has no attribute 'stream' What must I do to query correctly the firestore db

Upvotes: 0

Views: 2487

Answers (2)

J Schmaltz
J Schmaltz

Reputation: 21

I had a very similar issue. My problem was that I was using db.collection(u'cars).document(u'blue).get(). I kept getting an error of Client 'Query' object has no attribute get().

My problem was that when I am creating this db.collection object, I have to use lists in order to allow for instances where I have sub-collections. If you have the most up to date firebase-admin and you still get this error, verify that your query object is valid. Mine was coming up with None but still created a <google.cloud.firestore_v1.transaction.Transaction object at XXXXX>

I would check that your collection name exists, and that your client app is initialized.

    firebase_admin.initialize_app(cred)

    db = firestore.Client()

tldr: verify client app started and that your search should return at least one document.

Upvotes: 1

Juan Lara
Juan Lara

Reputation: 6854

You might be on an older version of the python library. stream() used to be called get(). Make sure you are on the latest version:

pip install --upgrade firebase-admin

Upvotes: 0

Related Questions