Words.objects.filter(foo__in=mylist)
--
Javier
cursor.execute("SELECT foo, bar FROM proj_words WHERE foo IN %s",
my_list)
but I can't off-hand remember which ones. If the back-end doesn't allow
that then you have little option but to generate your own SQL. The
required escape function is extremely simple:
def sqlesc(s):
return replace("'", "''")
and the SQL generation would read something like (again, untested):
sql = "SELECT foo, bar FROM proj_words WHERE foo IN (%s)" % \
", ".join("'%s'" % sqlesc(s) for s in my_list)
Personally I would do everything I could to avoid this construct, however.
regards
Steve
--
DjangoCon US 2010 September 7-9 http://djangocon.us/
but I can't off-hand remember which ones. If the back-end doesn't allow
that then you have little option but to generate your own SQL. The
required escape function is extremely simple:
def sqlesc(s):
return replace("'", "''")