-
Notifications
You must be signed in to change notification settings - Fork 0
/
fire.py
32 lines (27 loc) · 959 Bytes
/
fire.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
from datetime import datetime
class Uploader:
def __init__(self):
# Fetching the service account key JSON file
cred = credentials.Certificate("serviceKey.json")
if not firebase_admin._apps:
firebase_admin.initialize_app(cred, {
"databaseURL": "https://multimodalai-default-rtdb.firebaseio.com/"
})
# Saving the data
ref = db.reference("contact/")
self.users_ref = ref.child("data")
def upload(self, label, ans1, ans2, ans3):
now = str(datetime.now()).split(".")[0].replace(" ", "--").replace(":", "-")
self.users_ref.update({
now: {
"label": label,
"Q1": ans1,
"Q2:": ans2,
"Q3": ans3,
}
})
upl = Uploader()
upl.upload('financial', "yes", "no", 'yes')