Tuple Error in Python


 
Thread Tools Search this Thread
Top Forums Programming Tuple Error in Python
# 1  
Old 07-22-2016
Tuple Error in Python

Hi,

I am getting the below error:
Code:
AttributeError: 'tuple' object has no attribute 'field_id'

This line is complaining on the below code snippet:
Code:
        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

Code:
import psycopg2.extras

Where I was supposed to handle the tuples correctly with:

Code:
psycopg2.extras.NamedTupleCursor

This User Gave Thanks to ChicagoBlues For This Post:
# 2  
Old 07-22-2016
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Create a C source and compile inside Python 1.4.0 to 3.7.0 in Python for ALL? platforms...

Hi all... As you know I like making code backwards compatible for as many platforms as possible. This Python script was in fact dedicated for the AMIGA A1200 using Pythons 1.4.0, 1.5.2, 1.6.0, 2.0.1, and 2.4.6 as that is all we have for varying levels of upgrades from a HDD and 4MB FastRam... (1 Reply)
Discussion started by: wisecracker
1 Replies

2. Shell Programming and Scripting

Python Name Error

Hi There, I have the following code: import time import paramiko node_list = for node in node_list: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(node, username='lord', password='xxxx') variables = {} stdin,... (3 Replies)
Discussion started by: infinitydon
3 Replies

3. Shell Programming and Scripting

**python** unable to read the background color in python

I am working on requirement on spreadsheet in python scripting. I have a spreadsheet containing cell values and with background color. I am able to read the value value but unable to get the background color of that particular cell. Actually my requirement is to read the cell value along... (1 Reply)
Discussion started by: giridhar276
1 Replies

4. Shell Programming and Scripting

python - string encoding error

I'm trying to pull a google calendar (successful) and then put the contents into a mysql db (almost successful). On one of the field I keep getting an encode error: #!/usr/bin/python from xml.etree import ElementTree import gdata.calendar.data import gdata.calendar.client import... (12 Replies)
Discussion started by: unclecameron
12 Replies

5. Shell Programming and Scripting

python script error

Hi I have written a script in python and used it inside Ubuntu and its worked for me. The script import email.utils, however in centos when I try to run the script I get: Traceback (most recent call last): File "./warning.py", line 4, in ? import email.utils ImportError: No... (2 Replies)
Discussion started by: programAngel
2 Replies

6. Programming

Python MySQL error

Hey all, I'm trying to enter some data into a database and I keep getting this error: Traceback (most recent call last): File "./ais_file_parser.py", line 77, in <module> cursor.execute(sql) File "/usr/lib/pymodules/python2.7/MySQLdb/cursors.py", line 166, in execute ... (1 Reply)
Discussion started by: pmd006
1 Replies

7. Solaris

Error in installing the mysql-python-1.2.3.tar.gz

Hi, I followed the step written in README. It got some error message when I type " #python setup.py build" running build running build_py copying MySQLdb/release.py -> build/lib.solaris-2.11-i86pc-2.4/MySQLdb running build_ext building '_mysql' extension /usr/lib/python2.4/pycc -DNDEBUG... (2 Replies)
Discussion started by: AlexCheung
2 Replies

8. Programming

Error in Python Embeded in Qt C++

hi i have an error in script language when run it i use python 2.4, CentOS 5.5, Qt C++ 2010/04 the error is SystemError: null argument to internal routine the Python Code def main(i): print i if __name__ == "__main__": main(i) the C++ Code PyObject *objModule =... (0 Replies)
Discussion started by: HanyM.Magdy
0 Replies

9. Shell Programming and Scripting

use python or awk to match names 'with error tolerance'

I think this is a very challenging problem I am facing and I have no idea how to deal with it Suppose I have two csv files A.csv Toyota Camry,1998,blue Honda Civic,1999,blue B.csv Toyota Inc. Camry, 2000km Honda Corp Civic,1500km I want to generate C.csv Toyota Camry,1998,blue... (7 Replies)
Discussion started by: grossgermany
7 Replies
Login or Register to Ask a Question