使用python中的firebase将文件夹(包含.csv文件)上载到dB

2024-06-28 19:27:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用firebase将文件夹(包含.csv文件)保存到数据库中。但我没有做到这一点。请帮帮我。

    import os


from firebase import firebase

firebase = firebase.FirebaseApplication("https://face-crime.firebaseio.com/")


path = r'C:\Users\Jshei\Desktop\Criminal Face\Crime 
    Record'
    files = []
     # r=root, d=directories, f = files
    for r, d, f in os.walk(path):
    for file in f:
    if '.csv' in file:
    files.append(os.path.join(r, file))



for f in files:
print(f)

Tags: 文件csvpathinfromimport文件夹数据库
1条回答
网友
1楼 · 发布于 2024-06-28 19:27:13
import pyrebase


# This is a SDK from firebase

config = {
    "apiKey": "your API key",
    "authDomain": "you domain",
    "databaseURL": "your db url",
    "projectId": "your id",
    "storageBucket": "bucket name",
    # Don't forget to format the "double-quotes" for the strings, firebase not make that!
    "messagingSenderId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "appId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "measurementId": "xxxxxxxxxxxxxx"
}

firebase = pyrebase.initialize_app(config)  # data from the config
storage = firebase.storage()  # storage of database

storage.child("Crime Record csv files/Crime Record_2020-08-28_21-37-01.csv").put(
    r"/home/folio/Desktop/xxxxxxxxxx.csv") #make sure to put 'r'

# Crime Record is a folder in project in the firebase, Crime Record xxx=xxx=xxx.csv is the file where the Crime info.
# is stored, has a location to fetch the data from the Crime Record.


storage.child("Crime Record Images/xxxxxx.jpg").put(
    r"/home/folio/Desktop/xxxxxxxxxxxx.jpg")
# Crime Record is a folder in project in the firebase, TrainingImage xxx-xxx.jpg is the file where the Crime info. is
# stored, has a location to fetch the data from the TrainingImage.

相关问题 更多 >