That's perfect. Thanks!

On Thursday, 10 April 2014 11:38:24 UTC+1, Simon King wrote:
>
> You can also use sqlalchemy.literal, which returns an object that you 
> can treat like a column: 
>
>   sqlalchemy.literal('string').like('whatever') 
>
> You may also be interested in the 'startswith' shortcut, which calls 
> .like under the hood 
>
>   sqlalchemy.literal('string').startswith(yourcolumn) 
>
> Simon 
>
> On Thu, Apr 10, 2014 at 11:35 AM, Mark Bird <[email protected]<javascript:>> 
> wrote: 
> > I'm sorry, forget my last response, I see what you mean now. 
> > 
> > Thanks a lot! 
> > 
> > 
> > On Thursday, 10 April 2014 11:31:23 UTC+1, Gunnlaugur Briem wrote: 
> >> 
> >> Hi, 
> >> 
> >> See ColumnElement docs: 
> >> 
> >> 
> >> 
> http://docs.sqlalchemy.org/en/rel_0_9/core/sqlelement.html#sqlalchemy.sql.expression.ColumnElement
>  
> >> 
> >> ... for your specific example you can call .like(...) on column 
> clauses: 
> >> 
> >> >>> print Column('foo', Text).like('bar%baz') 
> >> foo LIKE :foo_1 
> >> 
> >> More generally, if you wanted some operator other than LIKE, existing 
> in 
> >> your DB dialect but not yet in SQLAlchemy, then you can use .op(...): 
> >> 
> >> >>> print Column('foo', Text).op('FNORD')('foo%') 
> >> foo FNORD :foo_1 
> >> 
> >> Cheers, 
> >> 
> >> Gulli 
> >> 
> >> 
> >> 
> >> On Thu, Apr 10, 2014 at 12:19 PM, Mark Bird <[email protected]> 
> wrote: 
> >>> 
> >>> I can't seem to find a way to do this without passing raw SQL to 
> >>> .filter() 
> >>> 
> >>> I could just do: 
> >>> 
> >>> .filter(column == func.substring('string', 1, 
> func.char_length(column))) 
> >>> 
> >>> but is it possible to do it with LIKE? 
> >>> 
> >>> I.e. I need to return all rows that match the beginning of a string, 
> so 
> >>> for 'string' I could match 's', 'st', 'str', etc. 
> >>> 
> >>> Thanks, 
> >>> 
> >>> Mark. 
> >>> 
> >>> 
> >>> -- 
> >>> You received this message because you are subscribed to the Google 
> Groups 
> >>> "sqlalchemy" 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/sqlalchemy. 
> >>> For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "sqlalchemy" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > To post to this group, send email to 
> > [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to