Exchange Extract Load Function

This commit is contained in:
Yam ZhengLim
2022-08-22 18:54:54 +08:00
parent 7c34c88d0b
commit 39e707ce46
13 changed files with 166 additions and 116 deletions
+23
View File
@@ -0,0 +1,23 @@
import os
from google.cloud import storage
import json
def login_cloudstorage_credential(credential):
try:
storage_client = storage.Client.from_service_account_json(credential)
return storage_client
except Exception as e:
print(e)
print("[FUNCTION_ERROR]-login_cloudstorage_credential")
return False
def upload_to_bucket(storage_client, blob_name, file_path):
try:
exchange_bucket = storage_client.get_bucket('exchange_bucket_raw')
blob = exchange_bucket.blob(blob_name)
blob.upload_from_filename(file_path)
return print("[Upload Complete]",file_path)
except Exception as e:
print(e)
print("[FUNCTION_ERROR]-upload_to_bucket",blob_name)
return False