This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Created by Antonio Cachuan (https://www.linkedin.com/in/antoniocachuan/) | |
#Example based in https://github.com/apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/snippets.py | |
import logging | |
import argparse | |
import requests | |
import apache_beam as beam | |
from apache_beam.io.gcp.internal.clients import bigquery | |
from datetime import datetime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More details https://medium.com/@alipazaga07 | |
from google.cloud import bigquery_reservation | |
import os | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
project_id = 'medium-sandbox' | |
client = bigquery_reservation.ReservationServiceClient() | |
parent = f"projects/{project_id}/locations/US" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import bigquery_connection | |
import os | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
project_id = 'medium-sandbox' | |
client = bigquery_connection.ConnectionServiceClient() | |
parent = f"projects/{project_id}/locations/US" | |
connections = list(client.list_connections(parent=parent)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud.bigquery_storage import BigQueryReadClient | |
from google.cloud.bigquery_storage import types | |
import os | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
project_id = 'medium-sandbox' | |
#Setting the client | |
client = BigQueryReadClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud.bigquery_storage import BigQueryReadClient | |
from google.cloud.bigquery_storage import types | |
import os | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
project_id = 'medium-sandbox' | |
#Setting the client | |
client = BigQueryReadClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read the full article https://medium.com/@alipazaga07 | |
import google.auth | |
from google.cloud import bigquery | |
from google.cloud import bigquery_storage | |
import os | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
# Create credentials object for both the BigQuery and BigQuery Storage clients | |
credentials, project_id = google.auth.default( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from google.cloud import bigquery_datatransfer_v1 | |
from google.protobuf.timestamp_pb2 import Timestamp | |
import os | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
client = bigquery_datatransfer_v1.DataTransferServiceClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Read more on https://medium.com/@alipazaga07 | |
#Listing all Data Transfer | |
from google.cloud import bigquery_datatransfer | |
import os | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
transfer_client = bigquery_datatransfer.DataTransferServiceClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from google.cloud import bigquery | |
import pandas as pd | |
# Reference the SA | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
# BigQuery client object. | |
client = bigquery.Client() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from google.cloud import bigquery | |
# Reference the SA | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='D:\medium\example-apis\key\key_bqsa.json' | |
# BigQuery client object. | |
client = bigquery.Client() | |
query = """ |