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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.