[url=http:/civis/viewtopic.php?p=28461379#p28461379:2fpiwywe said:C0rinthian[/url]":2fpiwywe][url=http:/civis/viewtopic.php?p=28460831#p28460831:2fpiwywe said:andrewme[/url]":2fpiwywe]You could simplify that to:
Code:cr.execute("select * from table where column like 'pattern%'")
Since there is no user input involved here and the strings are all constant, there is no risk of SQL injection and no need to use bound parameters in this case.
It's a bad pattern to get in the habit of regardless. There is literally no downside to using parameters, so just use them everywhere and you never need to worry about remembering what might be coming from user input.
As long as we are making suggestions regarding best practices, I have two more:
- Why not turn this into a stored procedure? Then the whole 'pattern%' detail can be hidden away
- I'd suggest explicitly referencing each column name in the select instead of doing "select *" as if the schema changes, you could be hiding bugs by using "select *"