Exemplo n.º 1
0
source_fields, target_fields = [], []
# for field in field_list:
#     if field not in talias_dict:
#         print "WARNING: %s not in field dictionary - will not be imported" % field
#         continue
#     fname = talias_dict[field]
#     fspec = fdict_lookup[fname]

#     source_fields.append(field)
#     target_fields.append(fname)

#     print field, fname

source_fields = field_list
target_fields = myspot.clean_field_aliases(field_list, table_dict_name)

target_fields_found = [i for i in target_fields if i != 'ALIAS_NOT_IN_FIELD_DICT']
# CHANGED: 2012-12-21 - tab_serial appended if does not already exist
# ... also see end of loop below
tab_serial_missing = False
if 'tab_serial' not in target_fields_found:
    tab_serial_missing = True
    target_fields_found.append('tab_serial')
debug = False
if debug:
    sys.exit(1)

# myspot.cr_mysql_tab(target_db, table_dict_name, target_fields_found,
#     raw_flg = 0,
#     import_flg = 1,
Exemplo n.º 2
0
    sql_multistmt(cursor, tspec['preflight'])

# Delete existing table
# Means field list order will not depend on sourcefields or sql_select
# But instead on sql_get cols
# stmt = "DROP TABLE IF EXISTS %s" % tab_name
# cursor.execute(stmt)

# Decide if this is a primary table or a derived one
# i.e. if you need an sql_create statement
if tspec['type'] == 'primary' and 'sql_select' not in tspec:
    # Assume that raw indexed 'source tables' always have the suffix _ix
    # Does not need the sql_create statement to be specified
    # CHANGED: 2012-12-21 - uses the same method as import_sql to resolve aliases
    tab_ix = tab_name + '_ix'
    target_fields = clean_field_aliases(tspec['sourcefields'], tab_name)
    fields = [i for i in target_fields if i != 'ALIAS_NOT_IN_FIELD_DICT']
    fields.append('tab_serial')
    # print falias_dict.items()
    # fields = ['tab_serial']
    # for f in tspec['sourcefields']:
    #     if f in fdict_lookup:
    #         fields.append(f)
    #     else:
    #         fields.append(falias_dict[f])
    # fields = [falias_dict[f] for f in tspec['sourcefields']]
    stmt = "SELECT %s FROM %s" % (', '.join(fields), tab_ix)
else:
    if 'sql_select_fields' in tspec:
        fields = tspec['sql_select_fields']
        stmt = tspec['sql_select'].replace('sql_select_fields',
Exemplo n.º 3
0
source_fields, target_fields = [], []
# for field in field_list:
#     if field not in talias_dict:
#         print "WARNING: %s not in field dictionary - will not be imported" % field
#         continue
#     fname = talias_dict[field]
#     fspec = fdict_lookup[fname]

#     source_fields.append(field)
#     target_fields.append(fname)

#     print field, fname

source_fields = field_list
target_fields = myspot.clean_field_aliases(field_list, table_dict_name)

target_fields_found = [
    i for i in target_fields if i != 'ALIAS_NOT_IN_FIELD_DICT'
]
# CHANGED: 2012-12-21 - tab_serial appended if does not already exist
# ... also see end of loop below
tab_serial_missing = False
if 'tab_serial' not in target_fields_found:
    tab_serial_missing = True
    target_fields_found.append('tab_serial')
debug = False
if debug:
    sys.exit(1)

# myspot.cr_mysql_tab(target_db, table_dict_name, target_fields_found,
Exemplo n.º 4
0
    sql_multistmt(cursor, tspec['preflight'])

# Delete existing table
# Means field list order will not depend on sourcefields or sql_select
# But instead on sql_get cols
# stmt = "DROP TABLE IF EXISTS %s" % tab_name
# cursor.execute(stmt)

# Decide if this is a primary table or a derived one
# i.e. if you need an sql_create statement
if tspec['type'] == 'primary' and 'sql_select' not in tspec:
    # Assume that raw indexed 'source tables' always have the suffix _ix
    # Does not need the sql_create statement to be specified
    # CHANGED: 2012-12-21 - uses the same method as import_sql to resolve aliases
    tab_ix = tab_name + '_ix'
    target_fields = clean_field_aliases(tspec['sourcefields'], tab_name)
    fields = [i for i in target_fields if i != 'ALIAS_NOT_IN_FIELD_DICT']
    fields.append('tab_serial')
    # print falias_dict.items()
    # fields = ['tab_serial']
    # for f in tspec['sourcefields']:
    #     if f in fdict_lookup:
    #         fields.append(f)
    #     else:
    #         fields.append(falias_dict[f])
    # fields = [falias_dict[f] for f in tspec['sourcefields']]
    stmt = "SELECT %s FROM %s" % (', '.join(fields), tab_ix)
else:
    if 'sql_select_fields' in tspec:
        fields = tspec['sql_select_fields']
        stmt = tspec['sql_select'].replace(