python - PYODBC - Too Few Parameters -
i have following code:
late_students = cursor.execute(''' select student.forename, student.surname, format(event_date_time,"long time") time_of_event events, student format(event_date_time,"short date") = date() , events.rfid = student.rfid , events.in_or_out = ? , format(event_date_time,"long time")>#08:40:00#''','in') rows = cursor.fetchall() print(rows)
it's simple , have many in program it, when run program, following error:
traceback (most recent call last): file "...coursework system 1.8.py", line 104, in <module> , format(event_date_time,"long time")>#08:40:00#''','in') pyodbc.error: ('07002', '[07002] [microsoft][odbc microsoft access driver] few parameters. expected 3. (-3010) (sqlexecdirectw)')
when add parameters, following error telling me have many parameters:
traceback (most recent call last): file "...\coursework system 1.8.py", line 104, in <module> , format(event_date_time,"long time")>#08:40:00#''','in','','') pyodbc.programmingerror: ('the sql contains 1 parameter markers, 3 parameters supplied', 'hy000')
what doing wrong?
long_time = 'long time' short_date = 'short date' todays_date = time.strftime('%d/%m/%y') reg_time = str('#08:40:00#') in = 'in' late_students = ''' select student.forename, student.surname, format(event_date_time,?) time_of_event events, student format(event_date_time,?) =? , events.rfid = student.rfid , events.in_or_out =? , format(event_date_time,?)>?''' parameters = (long_time, short_date,todays_date, in, long_time, reg_time) cursor.execute(late_students, parameters)
Comments
Post a Comment