Revision 2580
Added by Aaron Marcuse-Kubitza over 12 years ago
sql.py | ||
---|---|---|
873 | 873 |
if not create: raise |
874 | 874 |
return put(db, table, row, pkey, row_ct_ref) # insert new row |
875 | 875 |
|
876 |
def into_table_name(out_table, mapping, is_func): |
|
877 |
str_ = str(out_table) |
|
878 |
if is_func: |
|
879 |
def col(out_col, in_col): |
|
880 |
# Add out_col |
|
881 |
out_col = sql_gen.to_name_only_col(out_col) |
|
882 |
str_ = '' |
|
883 |
if out_col.name != 'value': str_ += str(out_col)+'=' |
|
884 |
|
|
885 |
# Add in_col |
|
886 |
in_col = sql_gen.to_name_only_col(sql_gen.remove_col_rename(in_col)) |
|
887 |
str_ += str(in_col) |
|
888 |
|
|
889 |
return str_ |
|
890 |
|
|
891 |
str_ += '('+(', '.join((col(k, v) for k, v in mapping.iteritems())))+')' |
|
892 |
else: str_ += '_pkeys' |
|
893 |
return str_ |
|
894 |
|
|
876 | 895 |
def put_table(db, out_table, in_tables, mapping, row_ct_ref=None, into=None, |
877 | 896 |
default=None, is_func=False): |
878 | 897 |
'''Recovers from errors. |
... | ... | |
891 | 910 |
''' |
892 | 911 |
out_table = sql_gen.as_Table(out_table) |
893 | 912 |
mapping = sql_gen.ColDict(mapping) |
894 |
if into == None: |
|
895 |
into = out_table.name |
|
896 |
if is_func: into += '()' |
|
897 |
else: into += '_pkeys' |
|
913 |
if into == None: into = into_table_name(out_table, mapping, is_func) |
|
898 | 914 |
into = sql_gen.as_Table(into) |
899 | 915 |
|
900 | 916 |
def log_debug(msg): db.log_debug(msg, level=1.5) |
Also available in: Unified diff
sql.py: put_table(): If into == None: For function calls, include the arguments in the into table name