python_apps/bigQuery_exercise/main.py
2023-11-03 14:49:12 +09:00

20 lines
707 B
Python

# 샘플 Python 스크립트입니다.
import pandas
import glob
from google.cloud import bigquery
from google.oauth2 import service_account
if __name__ == '__main__':
key_path = glob.glob("./config/*.json")[0]
credentials = service_account.Credentials.from_service_account_file(key_path)
client = bigquery.Client(credentials=credentials, project=credentials.project_id)
sql = f"""SELECT * FROM `skb-home-ga4.analytics_319633764.events_20230906` LIMIT 10"""
query_job = client.query(sql)
df = query_job.to_dataframe()
print(df)
#skb-home-ga4.analytics_319633764
#skb-biz-ga4.analytics_320354291
#skb-cds-ga4.analytics_259129513
#skb-bds-ga4.analytics_259510316