-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
41 lines (35 loc) · 2.2 KB
/
db.py
File metadata and controls
41 lines (35 loc) · 2.2 KB
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
33
34
35
36
37
38
39
40
41
# -----------------------------------------------------------
# initialization of database instances
# Firebase, Google Drive, SQLite
#
# (C) 2021-2024 Juan-Francisco Reyes, Cottbus, Germany
# Brandenburg University of Technology, Germany.
# Released under MIT License
# email pacoreyes.zwei@gmail.com
# -----------------------------------------------------------
from google.cloud import firestore
import gspread
from lib.utils import load_json_file
from oauth2client.service_account import ServiceAccountCredentials
""" Initialize Firestore """
# Initialize Firestore database instance
firestore_db = firestore.Client.from_service_account_json('credentials/firebase_credentials.json')
""" Initialize Google Sheets """
gdrive_scope = ["https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/drive"]
sheet_id_1 = load_json_file("credentials/gsheets_credentials.json")["sheet_id_1"]
sheet_id_2 = load_json_file("credentials/gsheets_credentials.json")["sheet_id_2"]
sheet_id_3 = load_json_file("credentials/gsheets_credentials.json")["sheet_id_3"]
sheet_id_4 = load_json_file("credentials/gsheets_credentials.json")["sheet_id_4"]
sheet_id_5 = load_json_file("credentials/gsheets_credentials.json")["sheet_id_5"]
sheet_id_6 = load_json_file("credentials/gsheets_credentials.json")["sheet_id_6"]
sheet_id_7 = load_json_file("credentials/gsheets_credentials.json")["sheet_id_7"]
cred = ServiceAccountCredentials.from_json_keyfile_name("credentials/gsheets_credentials.json", gdrive_scope)
client = gspread.authorize(cred)
spreadsheet_1 = client.open_by_key(sheet_id_1) # Initialize the spreadsheet 1 (websites, user )
spreadsheet_2 = client.open_by_key(sheet_id_2) # Initialize the spreadsheet 2 (dataset1)
spreadsheet_3 = client.open_by_key(sheet_id_3) # Initialize the spreadsheet 3 (dataset1_seminar - dataset2)
spreadsheet_4 = client.open_by_key(sheet_id_4) # Initialize the spreadsheet 4 (dataset3)
spreadsheet_5 = client.open_by_key(sheet_id_5) # Initialize the spreadsheet 5 (dataset1_seminar - dataset1)
spreadsheet_6 = client.open_by_key(sheet_id_6) # Initialize the spreadsheet 6 (dataset2)
spreadsheet_7 = client.open_by_key(sheet_id_7) # Initialize the spreadsheet 7 (dataset2 reclass final)