0

from table country in postgres :

id country_code country_desc
1 US United States
2 GB United Kingdom
3. GR Greece
4 CA Canada

i retrieve column country_code using sqlalchemy.My db is set to utf-8:

 engine = sql.create_engine(connectionString)
 countries = engine.execute('select country_code from country')
 for country in countries:
 print(country)

which returns:

('US',)
('GB',)
('GR',)
('CA',)

instead of

 US
 GB
 GR
 CA

I have no idea why.

asked Jan 24, 2020 at 22:07

2 Answers 2

1

Have you tried something like:

countries.country_code or countries.["country_code"]

answered Jan 24, 2020 at 22:14
Sign up to request clarification or add additional context in comments.

Comments

0
 engine = sql.create_engine(connectionString)
 countries = engine.execute('select country_code from country')
 for country in countries:
 print(country[0])

did the job

answered Jan 24, 2020 at 22:19

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.