Get that crucial report in Slack Channel

pip install google-cloud-bigqueryfrom import bigquery#setting up authourization
client = bigquery.Client.from_service_account_json("your_keys.json")
#query you are interested in my_query = """

select * from my_table
where my_condition = 'my_condition';
#making the API request and get the data into dataframedf = client.query(my_query).to_dataframe()if df.empty:
print('no results, please check query or if table is populated')
print("Fetch data success,", len(df))
ax = df.plot(kind='bar', figsize=(20,16), color="green", fontsize=13)


ax.set_title("Stats_Today", fontsize=22)

ax.set_ylabel("Record Count", fontsize=15)

ax.set_xlabel("Date", fontsize=15)

fig = ax.get_figure()

#saving figure at folder, saving at airflow folder
fig.savefig(airflow_home+'Stats_Today.png', bbox_inches = "tight")
#reading variables from the file, these are coming from airflowkpi_variables = Variable.get("kpi_variables_secret", deserialize_json=True)

url = kpi_variables["url"]
def upload_graph():
#uploading to slack
querystring = {"token":access_token}
payload = {"channels":"my_channel"} #your channel
file_upload = {"file": (airflow_home+"Stats_Today.png", open(airflow_home+"Stats_Today.png", 'rb'), 'image/png')}
headers = {"Content-Type": "multipart/form-data",}
response =, data=payload, params=querystring, files=file_upload)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store