MCPcopy Index your code
hub / github.com/webpy/webpy / select

Method select

web/db.py:831–870  ·  view source on GitHub ↗

Selects `what` from `tables` with clauses `where`, `order`, `group`, `limit`, and `offset`. Uses vars to interpolate. Otherwise, each clause can be a SQLQuery. >>> db = DB(None, {}) >>> db.select('foo', _test=True) <sql: 'SELECT * FROM fo

(
        self,
        tables,
        vars=None,
        what="*",
        where=None,
        order=None,
        group=None,
        limit=None,
        offset=None,
        _test=False,
    )

Source from the content-addressed store, hash-verified

829 return ResultSet(cursor)
830
831 def select(
832 self,
833 tables,
834 vars=None,
835 what="*",
836 where=None,
837 order=None,
838 group=None,
839 limit=None,
840 offset=None,
841 _test=False,
842 ):
843 """
844 Selects `what` from `tables` with clauses `where`, `order`,
845 `group`, `limit`, and `offset`. Uses vars to interpolate.
846 Otherwise, each clause can be a SQLQuery.
847
848 >>> db = DB(None, {})
849 >>> db.select('foo', _test=True)
850 <sql: 'SELECT * FROM foo'>
851 >>> db.select(['foo', 'bar'], where="foo.bar_id = bar.id", limit=5, _test=True)
852 <sql: 'SELECT * FROM foo, bar WHERE foo.bar_id = bar.id LIMIT 5'>
853 >>> db.select('foo', where={'id': 5}, _test=True)
854 <sql: 'SELECT * FROM foo WHERE id = 5'>
855 """
856 if vars is None:
857 vars = {}
858
859 sql_clauses = self.sql_clauses(what, tables, where, group, order, limit, offset)
860 clauses = [
861 self.gen_clause(sql, val, vars)
862 for sql, val in sql_clauses
863 if val is not None
864 ]
865 qout = SQLQuery.join(clauses)
866
867 if _test:
868 return qout
869
870 return self.query(qout, processed=True)
871
872 def where(
873 self,

Callers 13

whereMethod · 0.95
testUnicodeMethod · 0.80
assertRowsMethod · 0.80
testWrongQueryMethod · 0.80
testPoolingMethod · 0.80
test_multiple_insertMethod · 0.80
test_result_is_trueMethod · 0.80
tMethod · 0.80
test_insert_returningMethod · 0.80
__contains__Method · 0.80

Calls 4

sql_clausesMethod · 0.95
gen_clauseMethod · 0.95
queryMethod · 0.95
joinMethod · 0.80

Tested by 10

testUnicodeMethod · 0.64
assertRowsMethod · 0.64
testWrongQueryMethod · 0.64
testPoolingMethod · 0.64
test_multiple_insertMethod · 0.64
test_result_is_trueMethod · 0.64
tMethod · 0.64
test_insert_returningMethod · 0.64