title: how to add a variable to an SQL query?
body: <p>I am trying to add argv[0] as variable to the SQL query below and running into compilation error below,what is the syntax to fix this?</p>
  
  <pre><code>#!/usr/bin/python
  import pypyodbc as pyodbc
  from sys import argv
  component_id=argv[0]
  server_name='odsdb.company.com'
  database_name='ODS'
  
      cnx = pyodbc.connect("DRIVER={SQL Server};SERVER="+server_name+";DATABASE="+database_name)
      db_cursor=cnx.cursor()
      SQL = 'SELECT Top 1 cr.ReleaseLabel ' + \
      'FROM [ODS].[v000001].[ComponentRevisions] cr ' + \
      'WHERE cr.ComponentId=' + component_id + \
      'ORDER BY cr.CreatedOn DESC' 
      resp_rows_obj=db_cursor.execute(SQL)
      print '('+', '.join([column_heading_tuple[0] for column_heading_tuple in resp_rows_obj.description])+')'
      for row in resp_rows_obj:
          print row
  </code></pre>
  
  <p>Error:-</p>
  
  <pre><code>pypyodbc.ProgrammingError: (u'42000', u"[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'BY'.")
  </code></pre>