Skip to content
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

Cannot store database reference in variable #44

Open
FinnMal opened this issue Nov 22, 2021 · 0 comments
Open

Cannot store database reference in variable #44

FinnMal opened this issue Nov 22, 2021 · 0 comments

Comments

@FinnMal
Copy link

FinnMal commented Nov 22, 2021

To make the code cleaner, I save the database references in a variable. However, this may lead to my entire database being deleted.

If I do NOT query the value from the database before "set ('test')", everything works as expected. If the value is loaded from the database beforehand, the complete database is deleted after "set". If only the value is queried from the database, nothing is deleted either.

Python version: 3.7.4
Pyrebase4 version: 4.5.0

This code deletes the database:

import pyrebase

firebase_config = {
    "apiKey": "..",
    "authDomain": "...",
    "databaseURL": "...",
    "projectId": "...",
    "storageBucket": "...",
    "messagingSenderId": "...",
    "appId": "...",
    "serviceAccount": '...'
}

firebase = pyrebase.initialize_app(firebase_config)
db = firebase.database()


queue_id = db.child('queue_id').child('4IYNzoZ63Am2XYkxMFXsN7').get().val()
status_ref = db.child('queue').child(queue_id).child('status')

status = status_ref.get().val()

status_ref.set('test')

And this works fine:

queue_id = db.child('queue_id').child('4IYNzoZ63Am2XYkxMFXsN7').get().val()
status_ref = db.child('queue').child(queue_id).child('status')

# status = status_ref.get().val()

status_ref.set('test')

After the "deletion" my database looks like this:
database_empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant