I have this query:
query_del = '''DELETE * FROM Students WHERE Students.[last_name] = "Q";'''
And I'm doing this for execute:
conn= pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\XXX\Database.accdb;')
curs = conn.cursor()
curs.execute(query_del)
curs.commit()
But I'm getting this error:
ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1
The database is current like:
ID last_name first_name E-mail Address
3 Buuuu B C
4 Cuuuu C D
70 W W
72 W W
74 W W
76 W W
78 W W
80 W W
82 W W
84 W W
86 W W
87 Q Q
88 W W
89 Q Q
90 W W
EDIT 1: The query this way works:
query_del = '''DELETE * FROM Students WHERE Students.[last_name] = 'Q';'''
But I really need to have double quotes in the variables because I have some last names like x'xxx'x
so I don't know how to DELETE them. The query with simple a double quotes works well in Access:
DELETE FROM Students WHERE Students.[last_name] = "W"; #Works in Access
DELETE FROM Students WHERE Students.[last_name] = 'W'; #Also Works in Access
How can I translate this to python and to pyodbc?