sqlalchemy.sql.expression.func may work for this: from sqlalchemy.sql.expression import func
... q_doc.filter(func.substring(model.Doc.FileNameStr, 22, 1)==search_str) ... 2012/3/8 Timuçin Kızılay <t...@savaskarsitlari.org>: > I have a query contains SUBSTRING in where clause: > > Select top 100 * from _Doc > where SUBSTRING(_Doc.FileNameStr, 22, 1) = '2' > --- > This query runs on mssql but I need to use that query from sa. > I could not find anything like this in SA documentatin. > > Here is what I tried so far: > > q_doc = dbsession.query(model.Doc) > q_doc = q_doc.filter(model.Doc.DocID >= ilk).filter(model.Doc.DocID <= > son) > q_doc = q_doc.filter(model.Doc.FileNameStr[21] == search_str) > q_doc = q_doc.order_by(model.Doc.DocID) > > of course, that gives errors. > > > -- > 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 > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.