How do you write a query using like with the mysql connector and python. I am trying to avoid sql injections and using an ORM is not an option.
param = 'bob'
select_query = mysql_conn.query_db("select * from table_one where col_name like '%?%' order by id asc limit 5", param)
No matter what I send in when the query gets executed I get the same results. I should be getting nothing.
When I use the below query I get an error.
select_query = mysql_conn.query_db("select * from table_one where col_name like %s order by id asc limit 5", param)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s order by id asc limit 5' at line 1