Project

General

Profile

« Previous | Next » 

Revision 2181

sql.py: put_table(): insert_(): Use insert_select() instead of run_query_into() if new option pkeys_table_exists is on

View differences:

lib/sql.py
733 733
            table_is_esc=table_is_esc)
734 734
    
735 735
    out_pkeys_ref = ['out_pkeys_'+temp_suffix]
736
    def insert_():
736
    def insert_(pkeys_table_exists=False):
737 737
        '''Inserts and capture output pkeys.'''
738 738
        cur = insert_select(db, out_table, mapping.keys(),
739 739
            *mk_select_(mapping.values()), returning=out_pkey,
......
748 748
        add_row_num(db, in_pkeys_ref[0]) # for joining it with output pkeys
749 749
        
750 750
        # Join together output and input pkeys
751
        run_query_into(db, *mk_select(db,
752
            [in_pkeys_ref[0], (out_pkeys_ref[0], {row_num_col: join_using})],
753
            pkeys_cols, start=0), into_ref=pkeys_ref)
751
        select_query = mk_select(db, [in_pkeys_ref[0],
752
            (out_pkeys_ref[0], {row_num_col: join_using})], pkeys_cols, start=0)
753
        if pkeys_table_exists:
754
            insert_select(db, pkeys_ref[0], pkeys_cols, *select_query)
755
        else: run_query_into(db, *select_query, into_ref=pkeys_ref)
754 756
    
755 757
    # Do inserts and selects
756 758
    try: insert_()

Also available in: Unified diff