-1
cursor.execute("SELECT [Employees].Employee_Name, [Salerys].Salery")
cursor.execute("FROM Employees")
cursor.execute("WHERE (([Employee_Name]="John"));")

cursor.execute("SELECT \[Employees\].Employee_Name, \[Salerys\].Salery")
pyodbc.Error: ('07002', '\[07002\] \[Microsoft\]\[ODBC Microsoft Access Driver\] Too few parameters. Expected 2. (-3010) (SQLExecDirectW)')

Started to use this package since couple of days ago. I want to know how to fix this error & why this error came.

Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48
Chamod_
  • 1
  • 1
  • 3
  • 6
    Pass the complete query to `execute`, not line by line. – snakecharmerb Jan 30 '23 at 10:22
  • @snakecharmerb tried, but same result – Chamod_ Jan 30 '23 at 11:14
  • 2
    @Chamod_ please make sure you put in the question the exact code you have, because there is no parameter or placeholder in what you've shown, plus that third line will raise a `SyntaxError`. – ljmc Jan 30 '23 at 11:19
  • Does this answer your question? [How do I split the definition of a long string over multiple lines?](https://stackoverflow.com/questions/10660435/how-do-i-split-the-definition-of-a-long-string-over-multiple-lines) – June7 Jan 30 '23 at 12:04

1 Answers1

0

Please share exact code, that will help understand the problem well. From what you've shared it seems to be syntax issue; please try following, see if it works:

query_filter = 'John'
result = cursor.execute("""
    SELECT [Employees].Employee_Name, [Salerys].Salery
    FROM Employees
    WHERE [Employee_Name]=?
""", query_filter)