SQLObject sql to python


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # select distinct author from blogtable where keyword = "dust";
  2.  
  3.  
  4. class Blog(SQLObject):
  5. class sqlmeta:
  6. table = 'blogtable'
  7.  
  8. author = StringCol()
  9. keyword = StringCol()
  10.  
  11. Blog.select(Blog.q.keyword=='dust', distinct=True)
  12. Version 2
  13. select = Select(
  14. [Blog.q.author],
  15. Blog.q.keyword=='dust',
  16. distinct=True,
  17. )
  18.  
  19. sql = connection.sqlrepr(select)
  20.  
  21. for author in connection.queryAll(sql):
  22. print author

URL: http://stackoverflow.com/questions/4120165/how-to-translate-this-to-sqlobject-select-distinct-columnname-where/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.