How to correct this encoding/decoding issue with lists?

From: Federico Leoni <effenobrazil(at)gmail(dot)com>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: How to correct this encoding/decoding issue with lists?
Date: 2015-06-08 23:14:51
Message-ID: CAPBBA9yfoU6xUT_yBsC1K2imnvNC=QxvaK2-zC4UZzCc+L5+tQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-novice by date

  From Date Subject
Next Message Norbert Kiam Maclang 2015-06-09 07:39:52 Tainted kernel possible caused by postgresql
Previous Message wanna_be 2015-06-08 16:05:37 Re: query nested levels in jsonb