title: Passing a list of values from Python to the IN clause of an SQL query
body: <p>I am trying to pass a list like below to a sql query</p>
  
  <pre><code>x = ['1000000000164774783','1000000000253252111']
  </code></pre>
  
  <p>I am using <strong>sqlalchemy</strong> and <strong>pyodbc</strong> to connect to sql:</p>
  
  <pre><code>import pandas as pd
  from pandas import Series,DataFrame
  import pyodbc
  import sqlalchemy
  
  cnx=sqlalchemy.create_engine("mssql+pyodbc://Omnius:MainBrain1@172.31.163.135:1433/Basis?driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0")
  </code></pre>
  
  <p>I tried using various string format functions to be used in the sql query. below is one of them</p>
  
  <pre><code>  xx = ', '.join(x)
    sql = "select * from Pretty_Txns where Send_Customer in (%s)" % xx
    df = pd.read_sql(sql,cnx)
  </code></pre>
  
  <p>All of them seem to convert it into a numeric format</p>
  
  <pre><code>(1000000000164774783, 1000000000253252111) instead of ('1000000000164774783','1000000000253252111')
  </code></pre>
  
  <p>And hence the query fails as datatype of Send_Customer is <strong>varchar(50)</strong> in SQL</p>
  
  <pre><code> ProgrammingError: (pyodbc.ProgrammingError) ('42000', '[42000] [Microsoft][SQL Server Native Client 11.0]
    [SQL Server]Error converting data type varchar to numeric. (8114) (SQLExecDirectW)') 
   [SQL: 'select * from Pretty_Txns where Send_Customer in (1000000000164774783, 1000000000253252111)']
  </code></pre>