Revision 2253
Added by Aaron Marcuse-Kubitza over 12 years ago
sql.py | ||
---|---|---|
817 | 817 |
in_pkeys_ref = [temp_prefix+'_in_pkeys'] |
818 | 818 |
while True: |
819 | 819 |
try: |
820 |
db.log_debug('Inserting new rows') |
|
820 | 821 |
cur = insert_select(db, out_table, mapping.keys(), |
821 | 822 |
*mk_main_select(mapping.values()), returning=out_pkey, |
822 | 823 |
into_ref=out_pkeys_ref, recover=True, table_is_esc=table_is_esc) |
... | ... | |
824 | 825 |
row_ct_ref[0] += cur.rowcount |
825 | 826 |
add_row_num(db, out_pkeys_ref[0]) # for joining with input pkeys |
826 | 827 |
|
827 |
# Get input pkeys corresponding to rows in insert
|
|
828 |
db.log_debug('Getting input pkeys corresponding to rows in insert')
|
|
828 | 829 |
run_query_into(db, *mk_main_select([in_pkey]), |
829 | 830 |
into_ref=in_pkeys_ref) |
830 | 831 |
add_row_num(db, in_pkeys_ref[0]) # for joining with output pkeys |
831 | 832 |
|
832 |
# Join together output and input pkeys
|
|
833 |
db.log_debug('Joining together output and input pkeys')
|
|
833 | 834 |
run_query_into_pkeys(*mk_select(db, [in_pkeys_ref[0], |
834 | 835 |
(out_pkeys_ref[0], {row_num_col: join_using})], pkeys, start=0)) |
835 | 836 |
|
... | ... | |
839 | 840 |
db.log_debug('Ignoring existing rows, comparing on '+str(join_cols)) |
840 | 841 |
select_joins = insert_joins + [(out_table, join_cols)] |
841 | 842 |
|
842 |
# Get pkeys of already existing rows
|
|
843 |
db.log_debug('Getting pkeys of already existing rows')
|
|
843 | 844 |
run_query_into_pkeys(*mk_select(db, select_joins, pkeys_cols, |
844 | 845 |
order_by=None, start=0, table_is_esc=table_is_esc)) |
845 | 846 |
|
846 |
# Save existing pkeys in temp table for joining on
|
|
847 |
db.log_debug('Saving existing pkeys in temp table for joining on')
|
|
847 | 848 |
existing_pkeys_ref = [temp_prefix+'_existing_pkeys'] |
848 | 849 |
run_query_into(db, *mk_select(db, pkeys_ref[0], [in_pkey], |
849 | 850 |
order_by=None, start=0, table_is_esc=True), |
Also available in: Unified diff
sql.py: put_table(): Added debug messages for every action performed