I want to run a Dynamic query in python.
I have a combobox with 4 values (Direct, Indirect, Intermediary, Pointed). What I want to do is to write a dynamic query to interrogate my database and return the count of items.
I have this code:
(val is used to retrieve the value from a combobox)
c=db.cursor()
val=var.get()
query='SELECT count(*) from table where field=' + val
c.execute(query)
Now the query works if I write it like query='SELECT count(*) from table where field="Direct"' but I want it to work dynamically.
Is there any solution?