I am working on a psycopg2 application for a customer.

I first used:

SELECT * from table

which worked fine with 'cursor.fetchone()'. But due to some technical details
between the customer's database and the database on my company's side where
I could not depend on the order of the fields, I had to switch to

SELECT fld1, fld2, .... fldN FROM table

This case appeared to work, but the cursor returned a tuple of only 1 item, containing
the 'stringification' of the fields, separated by commas. This is obviously wrong, and would
be easy to workaround except that the data has commas in it in places.

I couldn't find this problem elsewhere and it occurs with psycopg 2.3.2 and 2.4 ... Any suggestions? I first tried SQLObject and SQLAlchemy but they were both too slow for this applicaiton.

6 Years
Discussion Span
Last Post by markmcwiggins

Are you include braces such as SELECT (fld1, fld2) FROM table? Looks like you are receiving a composite type instead of a record.


Yes, SELECT (fld1, fld2 ...) from table ... was just in a hurry typing the message.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.