Python - post 在 Firebase 中
Python - post in firebase
我想制作一个 python 脚本作为我的 firebase 应用程序的后端。
我想 post,在特定时间,firebase 中的一个对象。但它发布了 3,4 或 5 次.. 例如,我只想要一条 jobStoreAllum () 记录。
感谢您的帮助
from time import sleep
import time
import datetime
from firebase import firebase
import urllib2, urllib, httplib
import json
import os
from functools import partial
firebase = firebase.FirebaseApplication('https://plante-.firebaseio.com/', None)
import schedule
def jobAllum():
x=1
y=True
firebase.put("/Interuptors/Elec01", "/value", x)
firebase.put("/Interuptors/Elec01", "/state", y)
def jobStoreAllum():
dateString = '%d/%m/%Y %H:%M:%S'
y=True
data = {"State": y,"Horodate":datetime.datetime.now().strftime(dateString) }
firebase.post('/Storage/Journee', data)
while True:
Hallum= firebase.get("/Autom/Prog1/Hallum", None)
schedule.every().day.at(Hallum).do(jobAllum)
schedule.every().day.at(Hallum).do(jobStoreAllum)
schedule.run_pending()
time.sleep(10)
您可以使用 Cloud Scheduler。
确保终止返回值的函数。
并注意功能超时,默认为 1 分钟,最大为 9 分钟。
您必须为该项目启用计费,并且您每月有 3 个免费作业,超过 3 个将收取 0.10 美元/作业的费用,而不是执行费用。
参见
我想制作一个 python 脚本作为我的 firebase 应用程序的后端。
我想 post,在特定时间,firebase 中的一个对象。但它发布了 3,4 或 5 次.. 例如,我只想要一条 jobStoreAllum () 记录。
感谢您的帮助
from time import sleep
import time
import datetime
from firebase import firebase
import urllib2, urllib, httplib
import json
import os
from functools import partial
firebase = firebase.FirebaseApplication('https://plante-.firebaseio.com/', None)
import schedule
def jobAllum():
x=1
y=True
firebase.put("/Interuptors/Elec01", "/value", x)
firebase.put("/Interuptors/Elec01", "/state", y)
def jobStoreAllum():
dateString = '%d/%m/%Y %H:%M:%S'
y=True
data = {"State": y,"Horodate":datetime.datetime.now().strftime(dateString) }
firebase.post('/Storage/Journee', data)
while True:
Hallum= firebase.get("/Autom/Prog1/Hallum", None)
schedule.every().day.at(Hallum).do(jobAllum)
schedule.every().day.at(Hallum).do(jobStoreAllum)
schedule.run_pending()
time.sleep(10)
您可以使用 Cloud Scheduler。 确保终止返回值的函数。 并注意功能超时,默认为 1 分钟,最大为 9 分钟。 您必须为该项目启用计费,并且您每月有 3 个免费作业,超过 3 个将收取 0.10 美元/作业的费用,而不是执行费用。
参见