title: Python cx_oracle bind variable with a list of items
body: <p>I have a query like this:</p>
  
  <pre><code>SELECT prodId, prod_name , prod_type FROM mytable WHERE prod_type in (:list_prod_names)
  </code></pre>
  
  <p>I want to get the information of a product, depending on the possible types are:  <code>"day", "week", "weekend", "month"</code>. Depending on the date it might be at least one of those option, or a combination of all of them. </p>
  
  <p>This info (List type) is returned by the function <code>prod_names(date_search)</code></p>
  
  <p>I am using cx_oracle bindings with code like:</p>
  
  <pre><code>def get_prod_by_type(search_date :datetime):
  
    query_path = r'./queries/prod_by_name.sql'
    raw_query = open(query_path).read().strip().replace('\n', ' ').replace('\t', ' ').replace('  ', ' ')
  
    print(sql_read_op)
    # Depending on the date the product types may be different
    prod_names(search_date)  #This returns a list with possible names
    qry_params = {"list_prod_names": prod_names} # See attempts bellow
    try:
        db = DB(username='username', password='pss', hostname="localhost")
        df = db.get(raw_query,qry_params)
    except Exception:
        exception_error = traceback.format_exc()
        exception_error = 'Exception on DB.get_short_cov_op2() : %s\n%s' % exception_error
        print(exception_error)
    return df
  </code></pre>
  
  <p>For this: <code>qry_params = {"list_prod_names": prod_names}</code> I have tried multiple different things such as: </p>
  
  <pre><code>prod_names = ''.join(prod_names) 
  prod_names = str(prod_names)
  prod_names =." \'"+''.join(prod_names)+"\'"
  </code></pre>
  
  <p>The only thing I have managed to get it work is by doing:</p>
  
  <pre><code>new_query = raw_query.format(list_prod_names=prodnames_for_date(search_date)).replace('[', '').replace(']','')
  </code></pre>
  
  <p>df = db.query(new_query)</p>
  
  <p>I am trying not to use <code>.format()</code> because is bad practie to do a .format to an sql to prevent attacks. </p>
  
  <p><code>db.py</code> contains among other functions: </p>
  
  <pre><code>def get(self, sql, params={}):
  cur = self.con.cursor()
              cur.prepare(sql)
              try:
                  cur.execute(sql, **params)
                  df = pd.DataFrame(cur.fetchall(), columns=[c[0] for c in cur.description])
              except Exception:
                  exception_error = traceback.format_exc()
                  exception_error = 'Exception on DB.get() : %s\n%s' % exception_error
                  print(exception_error)
                  self.con.rollback()
              cur.close()
              df.columns = df.columns.map(lambda x: x.upper())
           return df
  </code></pre>
  
  <p><strong>I would like to be able to do a type binding.</strong> </p>
  
  <p>I am using:</p>
  
  <ul>
  <li>python = 3.6 </li>
  <li>cx_oracle = 6.3.1</li>
  </ul>
  
  <p>I have read the followig articles but I a still unable to find a solution:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/32868717/python-cx-oracle-bind-variables/33882805#33882805">Python cx_Oracle bind variables</a></li>
  <li><a href="https://stackoverflow.com/questions/45422178/python-cx-oracle-sql-with-bind-string-variable">Python cx_Oracle SQL with bind string variable</a></li>
  <li><a href="https://stackoverflow.com/questions/15237919/search-for-name-in-cx-oracle/15242393#15242393">Search for name in cx_Oracle</a></li>
  </ul>