Reputation: 11
I have an existing access query for example called *RunExampleQuery:
select name from table_x where date = [start];
But I can't seem to find the sql code that will run this query i.e
sql = """SELECT * FROM *RunExampleQuery WHERE [start] = ?"""
params = (datetime.date(2016,11,25))
cursor.execute(sql,params)
Thanks for your help in advance.
Upvotes: 1
Views: 581
Reputation: 107727
Couple of items are the issue:
[start]
field must exist in RunExampleQuery in order to use it in WHERE
clauseRunExampleQuery
select name, [start] from table_x;
Tuple Parameterization
sql = """SELECT * FROM [RunExampleQuery] WHERE [start] = ?"""
params = datetime.date(2016,11,25)
cursor.execute(sql, (params,))
List Parameterization
sql = """SELECT * FROM [RunExampleQuery] WHERE [start] = ?"""
params = datetime.date(2016,11,25)
cursor.execute(sql, [params])
Upvotes: 1