From 9fb28c5571a73d9ca43f742402b6c2ad5d9796ff Mon Sep 17 00:00:00 2001 From: peacetara Date: Fri, 3 Feb 2012 11:42:13 -0800 Subject: [PATCH] update the select() to show what it returns, so that the documentation is more complete. --- web/db.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/db.py b/web/db.py index f0af55b7..d8a506f8 100644 --- a/web/db.py +++ b/web/db.py @@ -673,6 +673,20 @@ def select(self, tables, vars=None, what='*', where=None, order=None, group=None >>> db.select(['foo', 'bar'], where="foo.bar_id = bar.id", limit=5, _test=True) + + + Return an iterator of storage items. example: + db.query("create table foo (age int, name varchar(30), created datetime);") + db.insert("INSERT INTO foo (age, name, created) VALUES (2, 'bob', NOW())") + r = db.select('foo') + r is now an iterator or you can get by item: + r[0] is the first row returned. + r[0].age == 2 + r[0].name == 'bob' + r[0].created is the timestamp for whatever NOW() is at the time of insert. + + len(r) gives you the rowcount, in this case 1. + """ if vars is None: vars = {} sql_clauses = self.sql_clauses(what, tables, where, group, order, limit, offset)