本文整理汇总了Python中pyrebase.initialize_app方法的典型用法代码示例。如果您正苦于以下问题:Python pyrebase.initialize_app方法的具体用法?Python pyrebase.initialize_app怎么用?Python pyrebase.initialize_app使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyrebase
的用法示例。
在下文中一共展示了pyrebase.initialize_app方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_firebase
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def setup_firebase():
"""
Instancia objeto de acesso do BD Firebase.
:return: o objeto do BD Firebase instanciado.
"""
config = {
"apiKey": os.environ.get('FIREBASE_API_KEY'),
"authDomain": os.environ.get('FIREBASE_PROJECT_ID') + ".firebaseapp.com",
"databaseURL": os.environ.get('FIREBASE_DB_URL'),
"storageBucket": os.environ.get('FIREBASE_PROJECT_ID') + ".appspot.com",
"serviceAccount": "./bandex_services_account.json"
}
try:
service_account = os.environ.get('FIREBASE_SERVICE_ACCOUNT')
f = open('./bandex_services_account.json', 'w')
f.write(service_account)
f.close()
except Exception as e:
print("Erro ao escrever no arquivo de service account: ", e)
else:
print("Service account configurado com sucesso.")
firebase = pyrebase.initialize_app(config)
db = firebase.database()
return db
示例2: __init__
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def __init__(self):
super(PyrebaseCommunicator, self).__init__()
self.JSONmatches = []
self.JSONteams = []
self.url = 'scouting-2017-5f51c'
config = {
'apiKey': 'mykey',
'authDomain': self.url + '.firebaseapp.com',
'databaseURL': 'https://' + self.url + '.firebaseio.com/',
'storageBucket': self.url + '.appspot.com'
}
app = pyrebase.initialize_app(config)
self.firebase = app.database()
self.fbStorage = app.storage()
#Turns inputted team (class) object into dict and puts on firebase
示例3: __init__
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def __init__(self):
''' Initialize auth, db, storage handles. '''
self.config = firebase_config
self.firebase = pyrebase.initialize_app(self.config)
self.auth = self.firebase.auth()
self.database = self.firebase.database()
self.storage = self.firebase.storage()
self.user = None
示例4: __init__
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def __init__(self):
if config['firebase']['apiKey']:
self.fb = pyrebase.initialize_app(config['firebase'])
self.auth = self.fb.auth()
self.user = self.auth.sign_in_with_email_and_password(config['firebase']['userId'], config['firebase']['userPassword'])
self.db = self.fb.database()
return None
示例5: test_add_values
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def test_add_values():
firebase = pyrebase.initialize_app(FIREBASE_CONFIG)
pprint(FIREBASE_CONFIG)
db = firebase.database()
db_store1 = db.child("store1")
# Add data (with default timestamped key)
timestamped_data = {"key1": "data1"}
db_store1.push(timestamped_data)
# Add data with custom key
key_value_data = {"key2": {"key2_1": "data2"}}
db_store1.push(key_value_data)
示例6: get_firebase
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def get_firebase():
firebase_credentials = get_credentials()
config = {
"apiKey": firebase_credentials[0],
"authDomain": firebase_credentials[1],
"databaseURL": firebase_credentials[2],
"storageBucket": firebase_credentials[3]
}
firebase = pyrebase.initialize_app(config)
return firebase
示例7: __init__
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def __init__(self, firebase_config):
self.firebase = pyrebase.initialize_app(firebase_config)
self.auth = self.firebase.auth()
self.storage = self.firebase.storage()
self.user = None
self.user_info = None
示例8: init
# 需要导入模块: import pyrebase [as 别名]
# 或者: from pyrebase import initialize_app [as 别名]
def init():
config = {
"apiKey": "AIzaSyAGTGrZCbaSYvCyTK3lSdJVDWCqRXwvEvo",
"authDomain": "gauge-97536.firebaseapp.com",
"databaseURL": "https://gauge-97536.firebaseio.com",
"storageBucket": "gauge-97536.appspot.com",
"serviceAccount": "firebase/fb.json"
}
global db
db = pyrebase.initialize_app(config).database()