Skip to content

Instantly share code, notes, and snippets.

@salvadorgascon
Last active February 23, 2024 12:55
Show Gist options
  • Save salvadorgascon/8cf7a825a7f16287742ca1ff422fab7b to your computer and use it in GitHub Desktop.
Save salvadorgascon/8cf7a825a7f16287742ca1ff422fab7b to your computer and use it in GitHub Desktop.
Create Dataset object in Google Cloud BigQuery
BIGQUERY_PROJECT_NAME = "project-XXXXX"
from google.cloud import bigquery
from google.cloud.exceptions import NotFound
from shared.loaders.bigquery_constants import BIGQUERY_PROJECT_NAME
def BigQueryCreateDataset(bigquery_client, bigquery_dataset_name):
print("Creating dataset", bigquery_dataset_name, '...', end='')
new_dataset = bigquery.Dataset(f'{BIGQUERY_PROJECT_NAME}.{bigquery_dataset_name}')
new_dataset.location = "EU"
bigquery_client.create_dataset(new_dataset)
print("OK")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment