Revision 2125
Added by Aaron Marcuse-Kubitza about 12 years ago
sql.py | ||
---|---|---|
629 | 629 |
if not create: raise |
630 | 630 |
return put(db, table, row, pkey, row_ct_ref) # insert new row |
631 | 631 |
|
632 |
def put_table(db, out_table, out_cols, in_tables, in_cols, pkey,
|
|
633 |
row_ct_ref=None, table_is_esc=False):
|
|
632 |
def put_table(db, out_table, in_tables, mapping, pkey, row_ct_ref=None,
|
|
633 |
table_is_esc=False): |
|
634 | 634 |
'''Recovers from errors. |
635 | 635 |
Only works under PostgreSQL (uses INSERT RETURNING). |
636 | 636 |
@return Name of the table where the pkeys (from INSERT RETURNING) are made |
... | ... | |
638 | 638 |
''' |
639 | 639 |
pkeys_table = clean_name(out_table)+'_pkeys' |
640 | 640 |
def insert_(): |
641 |
return insert_select(db, out_table, out_cols,
|
|
642 |
*mk_select(db, in_tables[0], in_cols, table_is_esc=table_is_esc),
|
|
641 |
return insert_select(db, out_table, mapping.keys(), *mk_select(db,
|
|
642 |
in_tables[0], mapping.values(), table_is_esc=table_is_esc),
|
|
643 | 643 |
returning=pkey, into=pkeys_table, recover=True, |
644 | 644 |
table_is_esc=table_is_esc) |
645 | 645 |
try: |
Also available in: Unified diff
sql.py: put_table(): Take a dict mapping out to in cols instead of separate in and out cols lists