How to use a list/tuple/array in Django with a raw SQL cursor

This does not work: from django.db import connection list_of_values = [ 1 , 2 , 3 ] with connection.cursor() as cursor: cursor.execute( """ SELECT * FROM my_model_table WHERE some_value IN %s """ , [ tuple (list_of_values), ]) results = cursor.fetchall() It will give you: django.db.utils.ProgrammingError: syntax error at or near "&#x27;(1,2,3)&#x27;" LINE 4: WHERE id IN &#x27;(1,2,3)&#x27; It used…