title: Passing Python List into SQL Query
body: <p>I am trying to cursor search through items in a field in an access table. I then append them to a list called 'distList'. I want to pass the list into an SQL Query builder 'WHERE' clause in the equation:</p>
  
  <pre><code>"Field1" in distList
  </code></pre>
  
  <p>or in long hand, it would look like this:</p>
  
  <pre><code>"Field1" in ('ds(c1)', 'ds(b1)', 'ds(c2)', 'ds(g1)')
  </code></pre>
  
  <p>The list looks like this:</p>
  
  <p>['ds(c1)', 'ds(b1)', 'ds(c2)', 'ds(g1)']</p>
  
  <p>The problem I am having is, the SQL equation above doesn't like to look 'in' a python list. It doesn't recognize the square brackets. It prefers round brackets, so I thought about using a tuple. The problem I am facing is I don't know how to build a tuple after cursor searching the items from the access table. here's my code example:</p>
  
  <pre><code>distList = []
  for lyr in arcpy.mapping.ListLayers(mxd, "", df):
      if lyr.name == "Disturbance":
             for row in arcpy.SearchCursor(lyr):
                  if "ds" in row.Field1:
                       distList.append(row.Field1)
      lyr.definitionQuery = '"Field1"' + "in " + distList
  </code></pre>
  
  <p>Can anyone suggest a way to get my list into a tuple or maybe just a better way to get my items into a format where they have round brackets instead of square ones?</p>
  
  <p>As a work around, I tried converting the list to string <code>str(distList)</code> and then replacing the brackets. That works fine, but it seems cumbersome and I'm sure there's a better way.</p>
  
  <p>Thanks,
  Mike</p>