You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pyrebase
# Konfigurasi database Firebase
config = {
"apiKey": "AIzaSyBxwerEkMk0IzRT_xN17HXhT-Qw743c-wg",
"authDomain": "testdoang-e8396.firebaseapp.com",
"projectId": "testdoang-e8396",
"storageBucket": "testdoang-e8396.appspot.com",
"messagingSenderId": "969724166255",
"appId": "1:969724166255:web:03f0aa356ea1c8b30d4d9a",
"measurementId": "G-LDLHNY5NN1"
}
# Inisialisasi koneksi ke Firebase
firebase = pyrebase.initialize_app(config)
# Inisialisasi instance database Firebase
db = firebase.database()
# CREATE (menambahkan data ke Firebase)
def tambah_data(nama, email, umur):
data = {
"nama": nama,
"email": email,
"umur": umur
}
db.child("pengguna").push(data)
print("Data berhasil ditambahkan")
# READ (mengambil data dari Firebase)
def baca_data():
data = db.child("pengguna").get()
if data.val() == None:
print("Belum ada data yang ditambahkan")
else:
print("Data yang tersimpan di Firebase:")
for pengguna in data.each():
print(pengguna.val())
# UPDATE (mengubah data di Firebase)
def ubah_data(key, nama, email, umur):
data = {
"nama": nama,
"email": email,
"umur": umur
}
db.child("pengguna").child(key).update(data)
print("Data berhasil diubah")
# DELETE (menghapus data di Firebase)
def hapus_data(key):
db.child("pengguna").child(key).remove()
print("Data berhasil dihapus")
# Menambahkan data ke Firebase
tambah_data("Andi", "[email protected]", 27)
# Membaca data dari Firebase
baca_data()
# # Mengubah data di Firebase
# ubah_data("-MaWsb9eRp1A0A3fzj5M", "Budi", "[email protected]", 30)
# # Menghapus data di Firebase
# hapus_data("-MaWsb9eRp1A0A3fzj5M")
root@minx-Lenovo-V145-14AST:/home/minx/belajar/fletApp/flerebase# python3 main.py
Traceback (most recent call last):
File "/home/minx/belajar/fletApp/flerebase/main.py", line 1, in <module>
import pyrebase
File "/usr/local/lib/python3.10/dist-packages/pyrebase/__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "/usr/local/lib/python3.10/dist-packages/pyrebase/pyrebase.py", line 1, in <module>
import requests
File "/usr/local/lib/python3.10/dist-packages/requests/__init__.py", line 63, in <module>
from . import utils
File "/usr/local/lib/python3.10/dist-packages/requests/utils.py", line 28, in <module>
from .structures import CaseInsensitiveDict
File "/usr/local/lib/python3.10/dist-packages/requests/structures.py", line 15, in <module>
class CaseInsensitiveDict(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
The text was updated successfully, but these errors were encountered:
i get error while adding data
my code
my python version
get error like this
The text was updated successfully, but these errors were encountered: