Chapter 10.3.3. Selecting Rows by Column Values

Another common access pattern is to select rows from a table based on a specific column value or a combination of column values. SQLObject gives you the selectBy() method. Suppose you have a table of web frameworks in various programming languages and you want to select only the Python-based ones:

class WebFramework(SQLObject): name = StringCol() language = StringCol() WebFramework.dropTable(ifExists=True) WebFramework.createTable() [WebFramework(name=f, language='Python') for f in ['TurboGears', 'DJango', 'Pylons']] [WebFramework(name=f, language='Java') for f in ['Struts', 'Shale', 'WebWork', 'Spring MVC']] [WebFramework(name=f, language='Ruby') for f in ['Ruby on Rails', 'ruby-waf']] sqlhub.processConnection.debug ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.