Chrome Extension

delete data from table

# Packages

import os
from google.cloud import bigquery
from google.oauth2 import service_account


# Parameters
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]='/Users/jmbenedetto/Library/Mobile Documents/com~apple~CloudDocs/#Formação/Dissertation/Research/02 Research v2/00 Base/key.json'

client = bigquery.Client(project=project_name)
dataset_ref = client.dataset(dataset_name)
load_config = bigquery.LoadJobConfig()


# Code

query = """
        DELETE 
        FROM dataset_name.table_name
        WHERE criteria;
"""
query_params = [
    bigquery.ArrayQueryParameter("file", "STRING", file_source)
]

job_config = bigquery.QueryJobConfig()
job_config.query_parameters = query_params
query_job = client.query(
    query,
    # Location must match that of the dataset(s) referenced in the query.
    location="EU",
    job_config=job_config,
)  # API request - starts the query

query_job.result(timeout=60.0)
assert query_job.state == "DONE"
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

Search Index Data (The code snippet can also be found with below search text)

gbq
Was this helpful?
0 Comments
Join Devsheet Ask a Question