Why I Hate Pyrebase by tomoyan

View this thread on steempeak.com
· @tomoyan ·
$14.01
Why I Hate Pyrebase
![image.png](https://images.ecency.com/DQmW2S5cesyReVjdD7NeYFt5Z8iex4wgVPQ4ozEi4pGBcAk/image.png)
[source](https://firebase.google.com/docs/database/rest/start)

I guess I should have used python-firebase... but I didn't pick python-firebase because there are two of them and I didn't know which one to choose 😂

But anyway, I started playing with Firebase the other day, and this python wrapper seemed pretty easy for firebase api.

What you have to do is pretty simple.
* Create a project on Firebase
* Add Firebase to your app
* Install pyrebase
And... start coing!

1. Go to [Firbase console](https://console.firebase.google.com/) 
Log in with your google account and create your project.
![1.png](https://images.ecency.com/DQmTaV69vgbeV69TKW3wABnXk6sCP5tNW267MrjRL3oCQ1m/1.png)
[source](https://console.firebase.google.com/)

Like this 👇
![image.png](https://images.ecency.com/DQmYWL772nKJkfvMvbbmYTrrN25tQRZfzfF6VRuzaD28ZGs/image.png)

Just "**Continue**"
![image.png](https://images.ecency.com/DQmVPZWviqfn6viQxVv6HWLoPrM3T64zW3hGMM9wv7cMo3Q/image.png)

And "**Create project**"
![image.png](https://images.ecency.com/DQmZZMshpw5QP3sm4j7e1YFiG6TWZcfFC4ARt25Z7iPYGU5/image.png)

Once project is created, add firebase to your app like this 👇
I will pick web but you can add iOS or Android too.
![image.png](https://images.ecency.com/DQmb33QTx9KfmDRCy82ESK3HnjZnsGS1wJqU8UPrKewjEXf/image.png)

Name your app and "**Register app**"
![image.png](https://images.ecency.com/DQmVDk2xAFzyi3L5pNv8YySv8GZx6oaw57r57Z1TufmDGzs/image.png)

You will get a config data like this 
![image.png](https://images.ecency.com/DQmZibDANTHv53AG2auHQ6FQHoHv8yVQUnmghGai6ZZm5Gv/image.png)
(this is not my config actually)
[source](https://www.youtube.com/watch?v=VnUXbo8JvvA&t=441s)

Project and app are all setup.

You only need this config part for python so copy and paste and make it like a real dictionary.

```
# Your web app's Firebase configuration
firebase_config = {
    "apiKey": "fireBaeIzaSyDJIQ7LiBG7QK7dUBPW3M1cGBFPTw1BE",
    "authDomain": "fireBae-9df46.firebaseapp.com",
    "databaseURL": "https://fireBae-9df46.firebaseio.com",
    "storageBucket": "fireBae-9df46.appspot.com",
}
```

Before you use Firebase in your python project, you need to install pyrebase library.
I have a better library so DO NOT actually install this library but this is how you install.
```pip install pyrebase```

Now the python part.
It is pretty simple.

```
import pyrebase

firebase_config = {
    "apiKey": "fireBaeIzaSyDJIQ7LiBG7QK7dUBPW3M1cGBFPTw1BE",
    "authDomain": "fireBae-9df46.firebaseapp.com",
    "databaseURL": "https://fireBae-9df46.firebaseio.com",
    "storageBucket": "fireBae-9df46.appspot.com",
}
firebase = pyrebase.initialize_app(firebase_config )

db = firebase.database()
```
This is pretty much it. You can just save data into firebase or retreive data from firebase.

**Save Data**
```
data = {
    "username": "tomoyan"
}
results = db.child("users").push(data)
```

**Retrieve Data**
```
users = db.child("users").get()
for user in users .each():
    print(user.key()) 
    print(user.val()) 
```

using pyrebase is pretty simple, but a lot of stuff aren't working like this documentation.
https://github.com/thisbejim/Pyrebase
So that is why I hate pyrebase.

I use **pyrebase4** instead.
So install this library
```pip install pyrebase4```

And the same code will work especially like these things
![image.png](https://images.ecency.com/DQmWG4GdDtAc89KCQ13c9qV2YM3dC3Dd2U9WMSrijYtsdGj/image.png)
[source](https://github.com/nhorvath/Pyrebase4)

What am I using this for?
![image.png](https://images.ecency.com/DQmSv5YBW2z3eYsfRndUVXu11MnVDY2TD74HNDg8LbqaqFr/image.png)
## 😉
<center>
[![image.png](https://images.blurt.buzz/DQmNow1i8RUp7WdTD1hgyXncPoKhJq5vziaGeoZc3gN9vuY/image.png)](https://blurtblock.herokuapp.com/tomoyan)
➡️ [Twitter ](https://twitter.com/tomoyanTweet)
</center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 31 others
properties (23)
post_id88,586,437
authortomoyan
permlinkwhy-i-hate-pyrebase
categorypython
json_metadata{"tags":["python","firebase","pyrebase","mini","blurt","upvote"],"image":["https:\/\/images.ecency.com\/DQmW2S5cesyReVjdD7NeYFt5Z8iex4wgVPQ4ozEi4pGBcAk\/image.png","https:\/\/images.ecency.com\/DQmTaV69vgbeV69TKW3wABnXk6sCP5tNW267MrjRL3oCQ1m\/1.png","https:\/\/images.ecency.com\/DQmYWL772nKJkfvMvbbmYTrrN25tQRZfzfF6VRuzaD28ZGs\/image.png","https:\/\/images.ecency.com\/DQmVPZWviqfn6viQxVv6HWLoPrM3T64zW3hGMM9wv7cMo3Q\/image.png","https:\/\/images.ecency.com\/DQmZZMshpw5QP3sm4j7e1YFiG6TWZcfFC4ARt25Z7iPYGU5\/image.png","https:\/\/images.ecency.com\/DQmb33QTx9KfmDRCy82ESK3HnjZnsGS1wJqU8UPrKewjEXf\/image.png","https:\/\/images.ecency.com\/DQmVDk2xAFzyi3L5pNv8YySv8GZx6oaw57r57Z1TufmDGzs\/image.png","https:\/\/images.ecency.com\/DQmZibDANTHv53AG2auHQ6FQHoHv8yVQUnmghGai6ZZm5Gv\/image.png","https:\/\/images.ecency.com\/DQmWG4GdDtAc89KCQ13c9qV2YM3dC3Dd2U9WMSrijYtsdGj\/image.png","https:\/\/images.ecency.com\/DQmSv5YBW2z3eYsfRndUVXu11MnVDY2TD74HNDg8LbqaqFr\/image.png","https:\/\/images.blurt.buzz\/DQmNow1i8RUp7WdTD1hgyXncPoKhJq5vziaGeoZc3gN9vuY\/image.png"],"links":["https:\/\/firebase.google.com\/docs\/database\/rest\/start","https:\/\/console.firebase.google.com\/","https:\/\/www.youtube.com\/watch?v=VnUXbo8JvvA&t=441s","https:\/\/github.com\/thisbejim\/Pyrebase","https:\/\/github.com\/nhorvath\/Pyrebase4","https:\/\/blurtblock.herokuapp.com\/tomoyan","https:\/\/twitter.com\/tomoyanTweet"],"app":"steemit\/0.2","format":"markdown"}
created2020-11-28 17:16:09
last_update2020-11-28 17:16:09
depth0
children0
net_rshares33,723,371,489,127
last_payout2020-12-05 17:16:09
cashout_time1969-12-31 23:59:59
total_payout_value7.419 SBD
curator_payout_value6.587 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length3,894
author_reputation870,963,589,956,079
root_title"Why I Hate Pyrebase"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (95)