Tuple Error in Python

Hi,

I am getting the below error:

AttributeError: 'tuple' object has no attribute 'field_id'

This line is complaining on the below code snippet:

        field_list = []
        for f in source_rows:
            field_list.append(f.field_id)

Where source_rows returns multiple rows of data, an field_list being a list should append multiple valules. Some help appreciated in figuring out where I'm messing up.

Thanks,
Aman

---------- Post updated at 03:30 PM ---------- Previous update was at 03:27 PM ----------

I hope I'm in the correct forum for Python questions.

---------- Post updated 07-22-16 at 12:52 PM ---------- Previous update was 07-21-16 at 03:30 PM ----------

Nevermind, I figured out the issue, it was with not using the library

import psycopg2.extras

Where I was supposed to handle the tuples correctly with:

psycopg2.extras.NamedTupleCursor
1 Like

Thank you for letting us know how you solved it. It will help other people with the same problem you encountered figure out how to fix it.