Project

General

Profile

« Previous | Next » 

Revision 2065

db_xml.py: put_table(): Use new insert_select()

View differences:

db_xml.py
131 131
        put()'s node param, but with the input column name prefixed by "$" in
132 132
        place of the column value.
133 133
    @param commit Whether to commit after each query
134
    @return returning_into tuple(table, col) Where the INSERT RETURNING values
135
        (pkeys) are made available
134 136
    '''
135 137
    def qual_name(table): return sql.qual_name(db, in_schema, table)
136 138
    def pkey(table): return sql.pkey(db, table, True)
......
158 160
        else: row[out_col] = (value, out_col) # value is literal value
159 161
    
160 162
    # Insert node
161
    out_cols = row.keys()
162
    map(sql.check_name, out_cols)
163
    select_query, params = sql.mk_select(db, qual_name(in_table), row.values(),
164
        table_is_esc=True)
165
    sql.run_query(db, 'INSERT INTO '+out_table+' ('+', '.join(out_cols)+') '
166
        +select_query, params)
163
    sql.insert_select(db, out_table, row.keys(), *sql.mk_select(db,
164
        qual_name(in_table), row.values(), table_is_esc=True))
167 165
    
168 166
    import sys; sys.stderr.write(str(node))
169 167
    if commit: db.db.commit()

Also available in: Unified diff