Skip to content

TypeError: tuple indices must be integers or slices, not str #5

@jensenity

Description

@jensenity

[2018-06-19 11:44:18,462] {models.py:1595} ERROR - tuple indices must be integers or slices, not str
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/airflow/models.py", line 1488, in _run_raw_task
result = task_copy.execute(context=context)
File "/usr/local/airflow/dags/productdata/ops/mysql_to_s3_operator.py", line 86, in execute
self.get_schema(hook, self.mysql_table)
File "/usr/local/airflow/dags/productdata/ops/mysql_to_s3_operator.py", line 94, in get_schema
new_dict['name']=i['COLUMN_NAME']
TypeError: tuple indices must be integers or slices, not str

There's an error if the tuple is a str.

When I change it to
[As-Is]

new_dict['name']=i['COLUMN_NAME']

new_dict['type']=i['COLUMN_TYPE']

[To-Be]
new_dict['name']=i[0] # COLUMN_NAME
new_dict['type']=i[1] # COLUMN_TYPE

No more error is shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions