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 <mark.a.b...@gmail.com> 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 sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to