Project

General

Profile

« Previous | Next » 

Revision 2054

sql.py: Added mk_select(), and use it in select()

View differences:

lib/sql.py
276 276

  
277 277
##### Basic queries
278 278

  
279
def select(db, table, fields=None, conds=None, limit=None, start=None,
280
    recover=None, cacheable=True, table_is_esc=False):
279
def mk_select(db, table, fields=None, conds=None, limit=None, start=None,
280
    table_is_esc=False):
281 281
    '''
282 282
    @param fields Use None to select all fields in the table
283 283
    @param table_is_esc Whether the table name has already been escaped
284
    @return tuple(query, params)
284 285
    '''
285 286
    if conds == None: conds = {}
286 287
    assert limit == None or type(limit) == int
......
312 313
    if missing: warnings.warn(DbWarning(
313 314
        'SELECT statement missing a WHERE, LIMIT, or OFFSET clause: '+query))
314 315
    
315
    return run_query(db, query, conds.values(), recover, cacheable)
316
    return (query, conds.values())
316 317

  
318
def select(db, *args, **kw_args):
319
    '''For params, see mk_select() and run_query()'''
320
    recover = kw_args.pop('recover', None)
321
    cacheable = kw_args.pop('cacheable', True)
322
    
323
    query, params = mk_select(db, *args, **kw_args)
324
    return run_query(db, query, params, recover, cacheable)
325

  
317 326
default = object() # tells insert() to use the default value for a column
318 327

  
319 328
def insert(db, table, row, returning=None, recover=None, cacheable=True,

Also available in: Unified diff