Variable bucket name in query

In this Getting Started with Python and InfluxDB v2.0 | InfluxData , Script for writing and querying points to InfluxDB with the Python Client,
Line 6, how do we pass bucket as variable instead of hard-coding it ?

query = 'from(bucket: "my-bucket")\

I tried multiple ways, but getting error.

This can be solved by using concatenating strings and var.

my-bucket = 'test'
query = 'from(bucket: "' + my-bucket + '")\
1 Like