Disrupt07 wrote: > > I have a table storing users' info. > table: userinfo > columns: name, surname, age, location, ... > > I need to query this table using SQLAlchemy's ORM methods (e.g. > select(), select_by(), get_by()). The query should be like > SELECT * FROM userinfo WHERE name LIKE 'Ben%' ORDER BY name, age > > Which SQLAlchemy method should I use? Can some provide me with an > example to solve my problem? > > Thanks
Columns have a 'like' method, as well as startswith and endswith, so for your particular example you could use something like this: <your_query>.select(userinfo.c.name.startswith('Ben')) Or: <your_query>.select(userinfo.c.name.like('Ben%')) Hope that helps, Simon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [EMAIL PROTECTED] 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 -~----------~----~----~----~------~----~------~--~---