2

I have a problem with a SQL query

import pyodbc 
cnxn = pyodbc.connect('DRIVER={Oracle dans OraClient11g_home1};Dbq=HBPSNHI1;UID=user;PWD=pswd')
cursor = cnxn.cursor()
date_init=datetime.datetime(2017,1,9)
date_fin=datetime.datetime(2017,2,2)
J_x=(20,10)
cursor.execute("SELECT * FROM TABLE WHERE ((DATE BETWEEN ? AND ?) AND (DAY IN ?))",(date_init,date_fin,J_x))

I have an error message

ProgrammingError: ('Invalid parameter type.  param-index=2 param-type=tuple', 'HY105')

I think it's because of the part ( DAY IN ? )

Thank you for your help

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Oussama Jabri
  • 674
  • 1
  • 7
  • 18
  • 1
    You can't put multiple values into a single SQL parameter. Try `(DAY IN (?,?))` and supply `20` and `10` as separate parameters. – khelwood Jun 19 '17 at 08:48
  • From the duplicate: *You need to use SQL parameters for each value.*, *For the in statement, that means you need to generate the parameters*. – Martijn Pieters Jun 19 '17 at 08:48

0 Answers0