samedi 4 juin 2022

Store Boolean values in Firebase using KivyMD Checkbox (Python)

I'm trying to store a boolean value in firebase firestore database using KivyMD and Python. In .kv file a Checkbox has been defined and if it is checked the value saving in the db should be true and otherwise it should be false. How to write the program please help me.

.kv

MDCheckbox:
    size_hint: None, None            
    id: agreed            

.py

def send_data(self):
    import firebase_admin
    from firebase_admin import credentials
    from firebase_admin import firestore

    cred = credentials.Certificate("cred.json")
    firebase_admin.initialize_app(cred)

    db = firestore.client()

    status = self.root.get_screen('add_st').ids.agreed

    data = {
        'Status': status
    }

    doc_ref = self.db.collection('Users').document('doc_name')

    doc_ref.set({
        'Status' = status
    })



Aucun commentaire:

Enregistrer un commentaire