Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Changed Readme
  • Loading branch information
katmakhan authored Aug 16, 2022
1 parent 0e57925 commit 998a1b2
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions Cloud Database/Database - Firebase/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#Firebase Imports
### Firebase Imports Functions

```python
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
```

### Initialising admin sdk
```python
cred = credentials.Certificate("/firebase-admin-key.json")


print("initilising firebase app")

#Initilising Database
Expand All @@ -17,29 +20,34 @@ firebase_admin.initialize_app(cred, {
app2 = firebase_admin.initialize_app(cred, {
'databaseURL': 'https://<project-id>-<database-instance>.firebaseio.com/'
}, name='app2')



# Fetch Data from firebase
```
### Fetch Data from firebase
```python
def fetch_data_firebase(path):
ref=db.reference('Users',app2).child(path)
data=ref.get()
print(data)
print("Succesfully fetched data from firebase ")
```

# Update Data from firebase
### Update Data from firebase
```python
def update_data_firebase(path,data):
ref=db.reference('Users',app2).child(path)
ref.set(data)
print("Succesfully updated the data in firebase")
```

# Delete Data from firebase
### Delete Data from firebase
```python
def delete_data_firebase(path):
ref=db.reference('Users',app2).child(path)
ref.delete()
print("Succesfully deleted the data from firebase")
```

# Main Function
### Sample Main Function
```python
def main():
fetch_data_firebase("Registered")

Expand All @@ -51,3 +59,4 @@ def main():
#Main program
if __name__ == '__main__':
main()
```

0 comments on commit 998a1b2

Please sign in to comment.