title: How to use variable in SQL query using Python
body: <p>I'm trying to pull data from my Google Ads account using their API. I'm using Python</p>
  <p>In the code example there is a query where I can specify the date range from which I want to collect results from my campaign.</p>
  <p>I would like to dynamically change de date everyday and run the script to get data from the previous day.</p>
  <p>My idea was to create a variable with the previous day date in the format Google API is requiering it, named &quot;yesterday&quot;.</p>
  <p>But I don't know how to use this variable into the query</p>
  <p>Here's a part of the code :</p>
  <pre><code>import argparse
  import sys
  
  from google.ads.googleads.client import GoogleAdsClient
  from google.ads.googleads.errors import GoogleAdsException
  from datetime import *
  
  yesterday_date = date.today() - timedelta(days=1)
  yesterday = yesterday_date.strftime(&quot;%Y-%m-%d&quot;)
  
  def main(client, customer_id):
  ga_service = client.get_service(&quot;GoogleAdsService&quot;)
  
  
  query = &quot;&quot;&quot;
      SELECT
        campaign.id,
        campaign.name,
        metrics.cost_micros,
        campaign.status
      FROM campaign
      WHERE segments.date = '2021-08-19'
          &quot;&quot;&quot;
  
  # Issues a search request using streaming.
  response = ga_service.search_stream(customer_id=customer_id, query=query)
  
  for batch in response:
      for row in batch.results:
          print(
              f&quot;Campaign with ID {row.campaign.id}, status is {row.campaign.status}, cost is {row.metrics.cost_micros} and name &quot;
              f'&quot;{row.campaign.name}&quot; was found.'
          )
  </code></pre>
  <p>I would like to do something like this :</p>
  <pre><code>WHERE segments.date = yesterday
  </code></pre>
  <p>I've tried to use sqlite3 library, to use cursor.execute() but I don't know how to use them properly.</p>
  <p>I'm a beginner so the answer might be very easy.</p>