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.

2 Answers 2

1

Have you tried something like:

countries.country_code or countries.["country_code"]

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

Comments

Your Answer

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.