Let say I have this query I would like to execute:
SELECT username FROM users WHERE username NOT IN ('user_a', 'user_b', 'user_c')
How do you run this using raw()? I've tried the following:
cursor = connections["db"].cursor()
cursor.execute("SELECT username FROM users WHERE username NOT IN (%s)", ['user_a,user_b,user_c'])
That doesn't work, since the list of user names would not be quoted. I then tried this:
cursor.execute("SELECT username FROM users WHERE username NOT IN (%s)", ["'user_a','user_b','user_c'"])
Then all the quotes will be escaped, and won't work.
Putting aside the discussion with using the ORM for a moment (there's a good reason for not using it), is it possible to do this using raw queries?