How to correct this encoding/decoding issue with lists? - Mailing list pgsql-novice

From Federico Leoni
Subject How to correct this encoding/decoding issue with lists?
Date
Msg-id CAPBBA9yfoU6xUT_yBsC1K2imnvNC=QxvaK2-zC4UZzCc+L5+tQ@mail.gmail.com
Whole thread Raw
List pgsql-novice
On a python script I have:

cur.execute(
    "SELECT product_template.name FROM public.pos_order_line,
public.product_template "
    "WHERE pos_order_line.product_id = product_template.id AND
pos_order_line.order_id >= 338 "
    "ORDER BY pos_order_line.id DESC;")
checkname = cur.fetchone()[0]
if checkname.startswith('#'):
    nametmp = checkname
    print checkname, nametmp

In this case the print output is ok:

# + Orégano # + Orégano

Process finished with exit code 0

But if I create a list for nametmp (and is what I need) I get:

    nametmp.insert(0, checkname)
    print checkname, nametmp

# + Orégano ['# + Or\xc3\xa9gano']

Process finished with exit code 0
I'm in Brazil, then my normal encoding should be latin1 but even if I put

# -*- coding: utf-8 -*-

at the start of my .py the result is the same. How can I resolve this issue?

Thanks.

Federico


pgsql-novice by date:

Previous
From: wanna_be
Date:
Subject: Re: query nested levels in jsonb
Next
From: Norbert Kiam Maclang
Date:
Subject: Tainted kernel possible caused by postgresql