title: sqlite3 variable substitution not working python3
body: <p>I'm trying to get the SQLlite3 variable substitution in Python working, but I always get the error:
  <em>sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.</em></p>
  <p>I've tried:</p>
  <pre><code>date_range = '10'
  
  with sqlite3.connect(DATABASE_LOGIN) as connection:
      cursor = connection.cursor()
  
      template = &quot;SELECT DISTINCT date FROM schedule WHERE date BETWEEN DATETIME('NOW') AND DATETIME('NOW', '-? DAYS') ORDER BY date&quot;
      cursor.execute(template, date_range)
  </code></pre>
  <p>and I know it's very bad form to use:</p>
  <pre><code>date_range = '10'
  
  with sqlite3.connect(DATABASE_LOGIN) as connection:
          cursor = connection.cursor()
  
          template = f&quot;SELECT DISTINCT date FROM schedule WHERE date BETWEEN DATETIME('NOW') AND DATETIME('NOW', '-{date_range} DAYS') ORDER BY date&quot;
          cursor.execute(template)
  </code></pre>
  <p>but for some reason the former query doesn't work.</p>