Hi All,

I'm wondering if there is a more elegant way to construct the
following piece of SQL:

SELECT * from MyTable where MyTable.MyColumn in ('foo', 'bar', 'baz');

The best I've come up with is the following:

>>> ls = ['foo', 'bar', 'baz']
>>> ls_str = str(ls).replace('[', '(').replace(']',')')
>>> ls_str
"('foo', 'bar', 'baz')"
>>> MyTable.filter(MyTable.c.MyColumn.op('in')(text(ls_str))

Which gives me the desired piece of SQL.

Ideally this would be expressed as:
>>> MyTable.filter(MyTable.c.MyColumn.in(ls))

Cheers,

Eoghan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to