1
我有以下代码:PYODBC - 太少参数
Late_Students = cursor.execute('''
SELECT Student.Forename, Student.Surname, FORMAT(Event_Date_Time,"Long Time") AS Time_Of_Event
FROM Events, Student
WHERE FORMAT(Event_Date_Time,"Short Date") = Date()
AND Events.RFID = Student.RFID AND
Events.In_Or_Out = ?
AND FORMAT(Event_Date_Time,"Long Time")>#08:40:00#''','In')
rows = cursor.fetchall()
print(rows)
这是一个非常简单的,我有很多我的程序喜欢它,但是当我运行该程序,我得到以下错误:
Traceback (most recent call last):
File "...Coursework System 1.8.py", line 104, in <module>
AND FORMAT(Event_Date_Time,"Long Time")>#08:40:00#''','In')
pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver]
Too few parameters. Expected 3. (-3010) (SQLExecDirectW)')
当我添加参数,我碰到下面的错误告诉我,我有太多的参数:
Traceback (most recent call last):
File "...\Coursework System 1.8.py", line 104, in <module>
AND FORMAT(Event_Date_Time,"Long Time")>#08:40:00#''','In','','')
pyodbc.ProgrammingError: ('The SQL contains 1 parameter markers, but 3
parameters were supplied', 'HY000')
我是什么做错了?
可能的重复[在Access中使用pyodbc给出“参数太少”错误]中的日期(http://stackoverflow.com/questions/28568110/working-with-dates-in-access-using- pyodbc-giving-too-few-parameters-error) –
@PeterWood我试过在那里发布的解决方案,但无济于事。由于某种原因,它仍然无法正常工作。 – Michael
你会得到什么错误? –