Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46083 > unrolled thread
| Started by | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-05-26 09:36 -0700 |
| Last post | 2013-05-31 08:13 -0700 |
| Articles | 20 on this page of 45 — 13 participants |
Back to article view | Back to comp.lang.python
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
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-05-27 13:17 -0700 |
| Message-ID | <f4c1b04a-7a50-418a-8be9-8a24609e261d@googlegroups.com> |
| In reply to | #46199 |
I have checked the database through phpMyAdmin and it is indeed UTF-8. I have no idea why python 3.3.1 chooses to work with latin-iso only....
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2013-05-28 08:34 -0600 |
| Message-ID | <mailman.2299.1369751680.3114.python-list@python.org> |
| In reply to | #46222 |
On 05/27/2013 02:17 PM, Νίκος Γκρ33κ wrote:
> I have checked the database through phpMyAdmin and it is indeed UTF-8.
>
> I have no idea why python 3.3.1 chooses to work with latin-iso only....
It's not python that is doing this here...
If you look at the source code to pymysql, I'm sure you will identify
the problem. In fact I'll even walk you through things.
The traceback you posted tells you what's going on and why, with
superfluous details removed for clarity:
File "/opt/python3/lib/python3.3/site-packages/pymysql/cursors.py", line
108, in execute:
query = query.encode(charset)
UnicodeEncodeError: 'latin-1' codec can't encode characters in position
46-52: ordinal not in range(256)
So there we have it. pymysql is actually explicitly calling .encode()
on a string and is using whatever character set is specified by the
local variable charset. If you look in cursors.py at that line, and
then a few lines above, you will find that charset is assigned to
conn.charset. This means that the charset is actually defined in the
connection object. So go look at connections.py. Sure enough, it shows
that charset is defined by default as "latin-1." That's no good for
you. So take a look at the __init__ method in connections.py. In there
you should find the necessary keyword argument you need to use when
creating the mysql connection to make sure the charset is utf-8.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-05-28 09:00 -0700 |
| Message-ID | <a3405148-c74b-49d9-a37f-5fc19e7434f4@googlegroups.com> |
| In reply to | #46292 |
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' ?
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-05-28 17:26 +0100 |
| Message-ID | <mailman.2303.1369758543.3114.python-list@python.org> |
| In reply to | #46302 |
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' )
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2013-05-28 10:40 -0600 |
| Message-ID | <mailman.2305.1369759217.3114.python-list@python.org> |
| In reply to | #46302 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <support@superhost.gr> |
|---|---|
| Date | 2013-05-28 09:45 -0700 |
| Message-ID | <d325d18f-9bb0-4a2e-9eb6-63d56c5aacbf@googlegroups.com> |
| In reply to | #46309 |
con = pymysql.connect( db = 'pelatologio', host = 'localhost', user = 'blabla', passwd = 'blabla', init_command='SET NAMES UTF8', charset = 'utf-8' )
produces this "God knows what" error traceback....
/home/nikos/public_html/cgi-bin/metrites.py in ()
217 template = htmldata + counter
218 elif page.endswith('.py'):
=> 219 htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + page )
220 template = htmldata.decode('utf-8').replace( 'Content-type: text/html; charset=utf-8', '' ) + counter
221
htmldata undefined, subprocess = <module 'subprocess' from '/opt/python3/lib/python3.3/subprocess.py'>, subprocess.check_output = <function check_output>, page = 'pelatologio.py'
/opt/python3/lib/python3.3/subprocess.py in check_output(timeout=None, *popenargs=('/home/nikos/public_html/cgi-bin/pelatologio.py',), **kwargs={})
584 retcode = process.poll()
585 if retcode:
=> 586 raise CalledProcessError(retcode, process.args, output=output)
587 return output
588
global CalledProcessError = <class 'subprocess.CalledProcessError'>, retcode = 1, process = <subprocess.Popen object>, process.args = '/home/nikos/public_html/cgi-bin/pelatologio.py', output = b'<!--: spam\nContent-Type: text/html\n\n<body b...Type\' object has no attribute \'id\'\n\n-->\n\n'
CalledProcessError: Command '/home/nikos/public_html/cgi-bin/pelatologio.py' returned non-zero exit status 1
args = (1, '/home/nikos/public_html/cgi-bin/pelatologio.py')
cmd = '/home/nikos/public_html/cgi-bin/pelatologio.py'
output = b'<!--: spam\nContent-Type: text/html\n\n<body b...Type\' object has no attribute \'id\'\n\n-->\n\n'
returncode = 1
with_traceback = <built-in method with_traceback of CalledProcessError object>
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2013-05-28 11:17 -0600 |
| Message-ID | <mailman.2307.1369761431.3114.python-list@python.org> |
| In reply to | #46310 |
On 05/28/2013 10:45 AM, Νίκος Γκρ33κ wrote:
> con = pymysql.connect( db = 'pelatologio', host = 'localhost', user = 'blabla', passwd = 'blabla', init_command='SET NAMES UTF8', charset = 'utf-8' )
>
> produces this "God knows what" error traceback....
Hey at least your database code is now working.
> /home/nikos/public_html/cgi-bin/metrites.py in ()
> 217 template = htmldata + counter
> 218 elif page.endswith('.py'):
> => 219 htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + page )
> 220 template = htmldata.decode('utf-8').replace( 'Content-type: text/html; charset=utf-8', '' ) + counter
> 221
> htmldata undefined, subprocess = <module 'subprocess' from '/opt/python3/lib/python3.3/subprocess.py'>, subprocess.check_output = <function check_output>, page = 'pelatologio.py'
> /opt/python3/lib/python3.3/subprocess.py in check_output(timeout=None, *popenargs=('/home/nikos/public_html/cgi-bin/pelatologio.py',), **kwargs={})
> 584 retcode = process.poll()
> 585 if retcode:
> => 586 raise CalledProcessError(retcode, process.args, output=output)
> 587 return output
> 588
> global CalledProcessError = <class 'subprocess.CalledProcessError'>, retcode = 1, process = <subprocess.Popen object>, process.args = '/home/nikos/public_html/cgi-bin/pelatologio.py', output = b'<!--: spam\nContent-Type: text/html\n\n<body b...Type\' object has no attribute \'id\'\n\n-->\n\n'
> CalledProcessError: Command '/home/nikos/public_html/cgi-bin/pelatologio.py' returned non-zero exit status 1
> args = (1, '/home/nikos/public_html/cgi-bin/pelatologio.py')
> cmd = '/home/nikos/public_html/cgi-bin/pelatologio.py'
> output = b'<!--: spam\nContent-Type: text/html\n\n<body b...Type\' object has no attribute \'id\'\n\n-->\n\n'
> returncode = 1
> with_traceback = <built-in method with_traceback of CalledProcessError object>
Again the traceback is telling you where to look for the problem. And
the problem is in your own script, pelatologio.py, though the line
number that's causing the problem is obscured.
Basically you want pelatologio.py to run and then you process the output
through a template, correct?
Well the traceback is telling you that pelatologio.py is erroring out.
In fact, subprocess is telling you that this process (your script) quit
with an error. Though the line number in pelatologio.py is unknown (the
traceback is obscured by your html processing code in your template
processor), the error message itself is not. Inside pelatologio.py
there is some object that you are trying to reference the "id" attribute
on it does not contain id.
So the problem is in pelatologio.py. Double check your code there. Try
to make a standalone test file you can run locally.
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-28 11:08 -0700 |
| Message-ID | <0e3ef4e1-800f-40fc-8cdb-f9d1467266b0@googlegroups.com> |
| In reply to | #46312 |
Τη Τρίτη, 28 Μαΐου 2013 8:17:05 μ.μ. UTC+3, ο χρήστης Michael Torrie έγραψε: > Basically you want pelatologio.py to run and then you process the output > through a template, correct? That is correct. > Inside pelatologio.py > there is some object that you are trying to reference the "id" attribute > on it does not contain id. > So the problem is in pelatologio.py. Double check your code there. Try > to make a standalone test file you can run locally. I have, i see no error, the error appears only when i append the charset directive into the connector, if i remove it the error dissapears.
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-05-28 14:14 -0400 |
| Subject | Re: Encodign issue in Python 3.3.1 (once again) |
| Message-ID | <mailman.2311.1369764879.3114.python-list@python.org> |
| In reply to | #46318 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, May 28, 2013 at 2:08 PM, <nagia.retsina@gmail.com> wrote: > Τη Τρίτη, 28 Μαΐου 2013 8:17:05 μ.μ. UTC+3, ο χρήστης Michael Torrie > έγραψε: > > > Basically you want pelatologio.py to run and then you process the output > > through a template, correct? > > That is correct. > > > Inside pelatologio.py > > there is some object that you are trying to reference the "id" attribute > > on it does not contain id. > > So the problem is in pelatologio.py. Double check your code there. Try > > to make a standalone test file you can run locally. > > I have, i see no error, the error appears only when i append the charset > directive into the connector, if i remove it the error dissapears. > -- > http://mail.python.org/mailman/listinfo/python-list > http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect Could this be the problem? ;) -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2013-05-28 12:19 -0600 |
| Message-ID | <mailman.2313.1369765168.3114.python-list@python.org> |
| In reply to | #46318 |
On 05/28/2013 12:08 PM, nagia.retsina@gmail.com wrote: > Τη Τρίτη, 28 Μαΐου 2013 8:17:05 μ.μ. UTC+3, ο χρήστης Michael Torrie > έγραψε: > >> Basically you want pelatologio.py to run and then you process the >> output through a template, correct? > > That is correct. > >> Inside pelatologio.py there is some object that you are trying to >> reference the "id" attribute on it does not contain id. So the >> problem is in pelatologio.py. Double check your code there. Try >> to make a standalone test file you can run locally. > > I have, i see no error, the error appears only when i append the > charset directive into the connector, if i remove it the error > dissapears. No, when you remove the charset directive your database call fails and thus things fail even earlier.
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-28 12:03 -0700 |
| Message-ID | <2217da95-178b-4af1-b816-af3ac5cb5f07@googlegroups.com> |
| In reply to | #46321 |
Τη Τρίτη, 28 Μαΐου 2013 9:19:21 μ.μ. UTC+3, ο χρήστης Michael Torrie έγραψε: > On 05/28/2013 12:08 PM, nagia.retsina@gmail.com wrote: > > > Τη Τρίτη, 28 Μαΐου 2013 8:17:05 μ.μ. UTC+3, ο χρήστης Michael Torrie > > > έγραψε: > > > > > >> Basically you want pelatologio.py to run and then you process the > > >> output through a template, correct? > > > > > > That is correct. > > > > > >> Inside pelatologio.py there is some object that you are trying to > > >> reference the "id" attribute on it does not contain id. So the > > >> problem is in pelatologio.py. Double check your code there. Try > > >> to make a standalone test file you can run locally. > > > > > > I have, i see no error, the error appears only when i append the > > > charset directive into the connector, if i remove it the error > > > dissapears. > > > > No, when you remove the charset directive your database call fails and > > thus things fail even earlier. Yes, it does create issues. i just tried to add it to metrites.py for testing and it breaks too. https://github.com/petehunt/PyMySQL/issues/38 Switching back to MySQLdb.
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-28 12:48 -0700 |
| Message-ID | <332e8acf-7484-49ba-b2e9-5861a001c2e6@googlegroups.com> |
| In reply to | #46327 |
But i think iam gonna fight it some more because mysqldb in python 3 has issues too :(
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-29 03:30 -0700 |
| Message-ID | <65dff60d-5b85-47ab-8f9b-f5578998e807@googlegroups.com> |
| In reply to | #46329 |
What makes us o sure it is a pymysql issue and not python's encoding issue?
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-30 00:18 -0700 |
| Message-ID | <84fc3a0c-16d3-493e-bf65-217e9995ab26@googlegroups.com> |
| In reply to | #46364 |
Τη Τετάρτη, 29 Μαΐου 2013 1:30:15 μ.μ. UTC+3, ο χρήστης nagia....@gmail.com έγραψε: > What makes us o sure it is a pymysql issue and not python's encoding issue? Someone help please.
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-30 01:16 -0700 |
| Message-ID | <6e432384-1ae4-418a-82c3-6e3f4664666b@googlegroups.com> |
| In reply to | #46439 |
Can ypou tell me how to install MySQLdb in python 3 using pip? pip install MySQLdb doesnt find the module.
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2013-05-30 03:29 -0600 |
| Message-ID | <mailman.2398.1369906211.3114.python-list@python.org> |
| In reply to | #46364 |
On 05/29/2013 04:30 AM, nagia.retsina@gmail.com wrote: > What makes us o sure it is a pymysql issue and not python's encoding > issue? The original traceback, which showed that the encoding error was happening in "/opt/python3/lib/python3.3/site-packages/pymysql/cursors.py", line 108. As was said, you solve that by passing a charset="utf-8" to the connection string. So doing that solved the encoding problem (a query is now being successfully built and sent to mysql) and went on to expose another problem (bug) in your code, but I cannot tell what that is, since the error happened in a subprocess and the traceback got sent to /dev/null. I suspect is has something to do with how the query results are being returned, or it could have something to do with the query itself. Python DB API does not specify exactly which style of prepared statements should be used by a given third-party module. So differences in syntax between how pymysql and MysqlDB define the variables could be the problem. In any case your course is clear. Run pelatologio.py outside of your templating system and see what the traceback says exactly now that the charset issue is fixed.
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-30 03:53 -0700 |
| Message-ID | <626eb9fc-3d4c-4818-8ce0-67562c9ed5b7@googlegroups.com> |
| In reply to | #46446 |
Τη Πέμπτη, 30 Μαΐου 2013 12:29:56 μ.μ. UTC+3, ο χρήστης Michael Torrie έγραψε: > On 05/29/2013 04:30 AM, nagia.retsina@gmail.com wrote: > > > What makes us o sure it is a pymysql issue and not python's encoding > > > issue? > > > > The original traceback, which showed that the encoding error was > > happening in > > "/opt/python3/lib/python3.3/site-packages/pymysql/cursors.py", line 108. > > As was said, you solve that by passing a charset="utf-8" to the > > connection string. > > > > So doing that solved the encoding problem (a query is now being > > successfully built and sent to mysql) and went on to expose another > > problem (bug) in your code, but I cannot tell what that is, since the > > error happened in a subprocess and the traceback got sent to /dev/null. > > I suspect is has something to do with how the query results are being > > returned, or it could have something to do with the query itself. > > Python DB API does not specify exactly which style of prepared > > statements should be used by a given third-party module. So differences > > in syntax between how pymysql and MysqlDB define the variables could be > > the problem. > > > > In any case your course is clear. Run pelatologio.py outside of your > > templating system and see what the traceback says exactly now that the > > charset issue is fixed. Good morning Michael, I'am afraid as much as you dont want to admin it that the moment i append the charset directive into the connections tring i receive a huge error which it can be displayed in: http://superhost.gr/cgi-bin/pelatologio.py This is run directly isolated form the templating system.
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-05-30 03:56 -0700 |
| Message-ID | <34e69a6d-83a8-420a-a2a2-2a9ef64601ba@googlegroups.com> |
| In reply to | #46453 |
Τη Πέμπτη, 30 Μαΐου 2013 1:53:33 μ.μ. UTC+3, ο χρήστης nagia....@gmail.com έγραψε:
> Τη Πέμπτη, 30 Μαΐου 2013 12:29:56 μ.μ. UTC+3, ο χρήστης Michael Torrie έγραψε:
>
> > On 05/29/2013 04:30 AM, nagia.retsina@gmail.com wrote:
>
> >
>
> > > What makes us o sure it is a pymysql issue and not python's encoding
>
> >
>
> > > issue?
>
> >
>
> >
>
> >
>
> > The original traceback, which showed that the encoding error was
>
> >
>
> > happening in
>
> >
>
> > "/opt/python3/lib/python3.3/site-packages/pymysql/cursors.py", line 108.
>
> >
>
> > As was said, you solve that by passing a charset="utf-8" to the
>
> >
>
> > connection string.
>
> >
>
> >
>
> >
>
> > So doing that solved the encoding problem (a query is now being
>
> >
>
> > successfully built and sent to mysql) and went on to expose another
>
> >
>
> > problem (bug) in your code, but I cannot tell what that is, since the
>
> >
>
> > error happened in a subprocess and the traceback got sent to /dev/null.
>
> >
>
> > I suspect is has something to do with how the query results are being
>
> >
>
> > returned, or it could have something to do with the query itself.
>
> >
>
> > Python DB API does not specify exactly which style of prepared
>
> >
>
> > statements should be used by a given third-party module. So differences
>
> >
>
> > in syntax between how pymysql and MysqlDB define the variables could be
>
> >
>
> > the problem.
>
> >
>
> >
>
> >
>
> > In any case your course is clear. Run pelatologio.py outside of your
>
> >
>
> > templating system and see what the traceback says exactly now that the
>
> >
>
> > charset issue is fixed.
>
>
>
> Good morning Michael,
>
>
>
> I'am afraid as much as you dont want to admin it that the moment i append the charset directive into the connections tring i receive a huge error which it can be displayed in:
>
>
>
> http://superhost.gr/cgi-bin/pelatologio.py
>
>
>
> This is run directly isolated form the templating system.
AttributeError: 'NoneType' object has no attribute 'id'
args = ("'NoneType' object has no attribute 'id'",)
with_traceback = <built-in method with_traceback of AttributeError object>
is the error while i have no id varibale just an 'ID' inside:
cur.execute('''SELECT ID FROM clients WHERE name = %s''', (name,) )
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-05-30 21:33 +1000 |
| Subject | Re: Encodign issue in Python 3.3.1 (once again) |
| Message-ID | <mailman.2405.1369913639.3114.python-list@python.org> |
| In reply to | #46453 |
On Thu, May 30, 2013 at 8:53 PM, <nagia.retsina@gmail.com> wrote: > Good morning Michael, > > I'am afraid as much as you dont want to admin it that the moment i append the charset directive into the connections tring i receive a huge error which it can be displayed in: > > http://superhost.gr/cgi-bin/pelatologio.py > > This is run directly isolated form the templating system. Your valid character set names can be found here: https://github.com/petehunt/PyMySQL/blob/master/pymysql/charset.py I found this simply by googling 'pymysql' and working through the call tree. Find what you want. Use it. You can probably get this information from the docs, too. Read them. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <support@superhost.gr> |
|---|---|
| Date | 2013-05-30 04:47 -0700 |
| Subject | Re: Encodign issue in Python 3.3.1 (once again) |
| Message-ID | <56a24a19-e3ca-4188-a617-63da252917f3@googlegroups.com> |
| In reply to | #46458 |
Τη Πέμπτη, 30 Μαΐου 2013 2:33:56 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Thu, May 30, 2013 at 8:53 PM, <nagia.retsina@gmail.com> wrote: > > > Good morning Michael, > > > > > > I'am afraid as much as you dont want to admin it that the moment i append the charset directive into the connections tring i receive a huge error which it can be displayed in: > > > > > > http://superhost.gr/cgi-bin/pelatologio.py > > > > > > This is run directly isolated form the templating system. > > > > Your valid character set names can be found here: > > > > https://github.com/petehunt/PyMySQL/blob/master/pymysql/charset.py > > > > I found this simply by googling 'pymysql' and working through the call tree. > > > > Find what you want. Use it. > > > > You can probably get this information from the docs, too. Read them. > > > > ChrisA I cant "fucking believe it". The moen i switched "charset = 'utf-8'" => "charset = 'utf8'" all started to work properly! Thank you very much Chris, i cnat belive i was lookign 3 days for that error and it was a matter of a dash removal.....My God!
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | comp.lang.python
csiph-web