title: How to pass variables for sql statements in python?
body: <p>I am a beginner in python.  I am doing a query on access database.  I was to pass a string variable to sql statement but can't figure it out for a double. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>qllname = 29221.0
  
  llname = "01-01-05-W2"
  
  sqlstatement = recordset.Open("SELECT * FROM LLD WHERE LLD = '%s'" % (llname),connection,1,3)
  
  for x in range(recordset.Fields.Count):
  
      fields_dict[x] = recordset.Fields.Item(x).Name
  
      print fields_dict[x], recordset.Fields.Item(x).Value, x
  
  
  sqlstatement2 = recordset2.Open("SELECT * FROM SWAWELLS WHERE WWDR_NO = '%d'" % (qllname),connection2,1,3)
  
  for x2 in range(recordset2.Fields.Count):
  
      print recordset2.Fields.Item(x2).Value, type(recordset2.Fields.Item(x2).Value)
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>LLD 01-01-05-W2 0
  X 678817.81875 1
  Y 5431052.45982 2
  Traceback (most recent call last):
    File "L:/temporary/start of test/accessnew--.py", line 25, in &lt;module&gt;
      sqlstatement2 = recordset2.Open("SELECT * FROM SWAWELLS WHERE WWDR_NO = '%d'" % (qllname),connection2,1,3)
    File "&lt;COMObject ADODB.Recordset&gt;", line 4, in Open
  com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft JET Database Engine', u'Data type mismatch in criteria expression.', None, 5003071, -2147217913), None)
  &gt;&gt;&gt; 
  </code></pre>