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?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/f84dc672-7d0c-429a-a4b6-9547b37106ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.