Re: [sqlalchemy] Is it possible to create a filter 'string' LIKE column + '%'?

2014-04-10 Thread Mark Bird
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' shortc

Re: [sqlalchemy] Is it possible to create a filter 'string' LIKE column + '%'?

2014-04-10 Thread Simon King
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 O

Re: [sqlalchemy] Is it possible to create a filter 'string' LIKE column + '%'?

2014-04-10 Thread Mark Bird
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 yo

Re: [sqlalchemy] Is it possible to create a filter 'string' LIKE column + '%'?

2014-04-10 Thread Mark Bird
Hi, thanks but I'm not talking about calling like on a column - I need to call like on a string literal. I tried doing text('string').like() but that doesn't work either. On Thursday, 10 April 2014 11:31:23 UTC+1, Gunnlaugur Briem wrote: > > Hi, > > See ColumnElement docs: > > > http://docs.sq

Re: [sqlalchemy] Is it possible to create a filter 'string' LIKE column + '%'?

2014-04-10 Thread Gunnlaugur Thor Briem
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 so

[sqlalchemy] Is it possible to create a filter 'string' LIKE column + '%'?

2014-04-10 Thread Mark Bird
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 cou