Skip to content
Advertisement

How can I perform search operation using raw sql query in django SQLITE

I’m trying to search string in the STAT table’s detection field like below:

JavaScript

Here, when I give the word or some character which are contained in detection_class, it returns an error message like thisTypeError('not all arguments converted during string formatting')),. and also if I try like detection_class=%s it works properly when gives while word else it returns None.

Advertisement

Answer

Don’t use string formatting when executing queries. Instead use a placeholder OR a named parameter.

JavaScript

I believe it is also possible to do it using the placeholder method as well, as shown below.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement