Project

General

Profile

« Previous | Next » 

Revision 2066

sql.py: Added mk_insert_select() and use it in insert_select()

View differences:

lib/sql.py
339 339
    query, params = mk_select(db, *args, **kw_args)
340 340
    return run_query(db, query, params, recover, cacheable)
341 341

  
342
default = object() # tells insert() to use the default value for a column
343

  
344
def insert_select(db, table, cols=None, select_query=None, params=None,
342
def mk_insert_select(db, table, cols=None, select_query=None, params=None,
345 343
    returning=None, recover=None, cacheable=True, table_is_esc=False):
346 344
    '''
347 345
    @param returning str|None An inserted column (such as pkey) to return
......
362 360
        check_name(returning)
363 361
        query += ' RETURNING '+returning
364 362
    
363
    return (query, params)
364

  
365
def insert_select(db, *args, **kw_args):
366
    '''For params, see mk_insert_select() and run_query()'''
367
    recover = kw_args.pop('recover', None)
368
    cacheable = kw_args.pop('cacheable', True)
369
    
370
    query, params = mk_insert_select(db, *args, **kw_args)
365 371
    return run_query(db, query, params, recover, cacheable)
366 372

  
373
default = object() # tells insert() to use the default value for a column
374

  
367 375
def insert(db, table, row, *args, **kw_args):
368 376
    '''For args, see insert_select()'''
369 377
    if lists.is_seq(row): cols = None

Also available in: Unified diff