1

Query Update in BiqQuery on Python

*

def upd_data(QUERY):
    query_job = client.query(QUERY)
    z = query_job.result()
    print(query_job.state, query_job.result, query_job.query_results

*

I get on print - bound method QueryJob.query_results of google.cloud.bigquery.job.QueryJob object at 0x000001CFDEC22748

I need - "N rows affected."

0

1 Answer 1

2

If you are running DML queries and want to know how many rows were affected then try this instead (this is in client version 0.31 but should work from 0.28):

query = """
  UPDATE table 
  SET col WHERE condition
"""

job = client.query(query)
result = job.result()
print("Total rows affected: ", job.num_dml_affected_rows)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.