Encodign issue in Python 3.3.1 (once again)

MRAB python at mrabarnett.plus.com
Tue May 28 12:26:07 EDT 2013


On 28/05/2013 17:00, Νίκος Γκρ33κ wrote:
> I do not know here to find connections.py Michael.
>
> But i do not understand since iam suing the following 2 statements, why a unicode error remains.
>
> #needed line, script does *not* work without it
> sys.stdout = os.fdopen(1, 'w', encoding='utf-8')
>
> # connect to database
> con = pymysql.connect( db = 'pelatologio', host = 'localhost', user = 'myself', passwd = 'mypass', init_command='SET NAMES UTF8' )
> cur = con.cursor()
>
> Shall i chnage the connector form 'pymysql' => 'MySQLdb' ?
>
A quick look at the documentation tells me that the charset can be
specified in the 'connect' call, something like this:

con = pymysql.connect( db = 'pelatologio', host = 'localhost', user = 
'myself', passwd = 'mypass', init_command='SET NAMES UTF8', charset = 
'utf-8' )




More information about the Python-list mailing list