Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46309

Re: Encodign issue in Python 3.3.1 (once again)

Date 2013-05-28 10:40 -0600
From Michael Torrie <torriem@gmail.com>
Subject Re: Encodign issue in Python 3.3.1 (once again)
References (2 earlier) <9560d43f-8100-4914-9a71-c30ab479ec35@googlegroups.com> <mailman.2251.1369665785.3114.python-list@python.org> <f4c1b04a-7a50-418a-8be9-8a24609e261d@googlegroups.com> <mailman.2299.1369751680.3114.python-list@python.org> <a3405148-c74b-49d9-a37f-5fc19e7434f4@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2305.1369759217.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 05/28/2013 10:00 AM, Νίκος Γκρ33κ wrote:
> I do not know here to find connections.py Michael.

It's part of the pymysql package that you installed.  Look in there (the
traceback even shows you where the file is).  But you actually don't
even need to look at it on your server.  You can see the source code for
it here:

https://github.com/petehunt/PyMySQL/tree/master/pymysql

> But i do not understand since iam suing the following 2 statements,
> why a unicode error remains.

The traceback told you why the error is happening.  inside the pymysql
library, there is a call to .encode(charset) on your query string.  And
the default charset is latin-1.  You've got to work out a way to change
that and I've already told you exactly how to find out what you need to
do.

> #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()

HINT: this line ^^^^^^ is what you have to modify by passing in a
particular keyword argument that sets the character set (no it's not the
init_command one).  You will have to look at connections.py's __init__
declaration and you should see what you need to pass in.

Yes I could have saved myself a lot of time and typing by giving you the
answer, but that isn't going to help you.  On the other hand, if you
want the easy way out, paypal some money to me and I'll just give you
the answer instead of trying to give you the tools you need to debug
this issue.  The answers are all in the source code to pymysql, which is
open source so you can always read (either on your own server file
system or on the git repository).

> 
> Shall i chnage the connector form 'pymysql' => 'MySQLdb' ?

No.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 09:36 -0700
  Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 11:20 -0700
  Re: Encodign  issue in Python 3.3.1 (once again) Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-26 16:53 -0400
    Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 14:26 -0700
      Re: Encodign issue in Python 3.3.1 (once again) Chris Angelico <rosuav@gmail.com> - 2013-05-27 07:44 +1000
      Re: Encodign  issue in Python 3.3.1 (once again) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-26 23:21 +0100
      RE: Encodign  issue in Python 3.3.1 (once again) Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-27 01:31 +0300
      Re: Encodign issue in Python 3.3.1 (once again) Chris Angelico <rosuav@gmail.com> - 2013-05-27 08:32 +1000
      Re: Encodign issue in Python 3.3.1 (once again) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-26 23:51 +0100
  Re: Encodign  issue in Python 3.3.1 (once again) Tim Roberts <timr@probo.com> - 2013-05-26 19:01 -0700
    Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 22:06 -0700
      Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-27 07:16 -0700
        Re: Encodign  issue in Python 3.3.1 (once again) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-27 15:45 +0100
          Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-27 08:37 -0700
            Re: Encodign issue in Python 3.3.1 (once again) Chris Angelico <rosuav@gmail.com> - 2013-05-28 01:52 +1000
              Re: Encodign issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-27 09:56 -0700
                Re: Encodign issue in Python 3.3.1 (once again) Chris Angelico <rosuav@gmail.com> - 2013-05-28 08:18 +1000
                Re: Encodign issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-27 22:55 -0700
                Re: Encodign issue in Python 3.3.1 (once again) rusi <rustompmody@gmail.com> - 2013-05-28 04:56 -0700
      Re: Encodign  issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-27 08:42 -0600
        Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-27 13:17 -0700
          Re: Encodign  issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-28 08:34 -0600
            Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-28 09:00 -0700
              Re: Encodign  issue in Python 3.3.1 (once again) MRAB <python@mrabarnett.plus.com> - 2013-05-28 17:26 +0100
              Re: Encodign  issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-28 10:40 -0600
                Re: Encodign  issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <support@superhost.gr> - 2013-05-28 09:45 -0700
                Re: Encodign  issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-28 11:17 -0600
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-28 11:08 -0700
                Re: Encodign issue in Python 3.3.1 (once again) Joel Goldstick <joel.goldstick@gmail.com> - 2013-05-28 14:14 -0400
                Re: Encodign  issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-28 12:19 -0600
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-28 12:03 -0700
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-28 12:48 -0700
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-29 03:30 -0700
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-30 00:18 -0700
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-30 01:16 -0700
                Re: Encodign  issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-30 03:29 -0600
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-30 03:53 -0700
                Re: Encodign  issue in Python 3.3.1 (once again) nagia.retsina@gmail.com - 2013-05-30 03:56 -0700
                Re: Encodign issue in Python 3.3.1 (once again) Chris Angelico <rosuav@gmail.com> - 2013-05-30 21:33 +1000
                Re: Encodign issue in Python 3.3.1 (once again) Νίκος Γκρ33κ <support@superhost.gr> - 2013-05-30 04:47 -0700
                Re: Encodign issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-30 08:35 -0600
                Re: Encodign issue in Python 3.3.1 (once again) Chris Angelico <rosuav@gmail.com> - 2013-05-31 00:40 +1000
                Re: Encodign issue in Python 3.3.1 (once again) Michael Torrie <torriem@gmail.com> - 2013-05-30 11:01 -0600
                Re: Encodign issue in Python 3.3.1 (once again) Chris Angelico <rosuav@gmail.com> - 2013-05-31 03:28 +1000
                Re: Encodign issue in Python 3.3.1 (once again) Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-05-31 08:13 -0700

csiph-web