top of page
  • Writer's pictureQuan Sheng

Database Google Firebase *FIRE*

Have you ever thought where are the data stored such as your accounts, details or maybe phone numbers.


Those are stored in a place called database where all your information are stored.

One of the popular database is Google Firebase


I need to first create a project for my database.


This is to allow me to store my data on this project











It took quite awhile to initialize the project that i have created but in the backend it is setting up a project space therefore it will take awhile to load.









This is how it should look like when you first enter. I feel this is user friendly, easy to navigate around.


First i have to ensure that the rule is true for read and write.

What is read and write?

read - Read data from database

write - Store data into database


Easy right? I am just setting the permission to allow read and write.

so first we are going to write data into our database using PYTHON!

Fun fact: you can use this platform for other uses as well such as apps or more!!


As you can read, i randomly generate a number for humidity and temperature to simulate the process. With this, i can implement it on the raspberry pi to collect such data with the humidity sensor which i have done before and automatically store in the database!

As i run the code, the data that are generated are stored in the google firebase with a uid created automatically for each data. This UID is generated by a new data path, with a server timestamp as its key. These keys look like -JiGh_31GA20JabpZBfa, so not numeric. We can create our own custom token for this as well.


Firebase with data being pushed


Now lets say you would like to update the data, such occurrence can happen on update profile.

We can make use of "patch" to update the temperature


What about deleting it? Maybe when someone wants to remove their profile?


We can make use of "delete" to delete the data from the google firebase


Firebase is a great platform to work on because if you would to accidentally delete your data, they can help you to recover your data.

The backups are stored on a google cloud storage bucket in an easily readable


Love what you see? Stay tune for more!!!

9 views

Kommentare


bottom of page