Re: Special Characters (Unicode, Ascii) in Python and MySQL



On Mon, 2007-01-01 at 21:57 -0800, ronrsr wrote:
I have an MySQL database called zingers. The structure is:

zid - integer, key, autoincrement
keyword - varchar
citation - text
quotation - text

I am having trouble storing text, as typed in latter two fields.
Special characters and punctuation all seem not to be stored and
retrieved correctly.

Special apostrophes and single quotes from Microsoft Word are causing a
special problem, even though I have ''ed all 's

perhaps the encoding of the database itself should be different? it is
currenlty latin_swedish_ci

Input and output is through a browser.

I think my problem may be that I need to encode the string before
saving it in the databse. Can anyone point me in the right direction
here?



here's the error message:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
95: ordinal not in range(128)
args = ('ascii', "update zingers set keywords =
'a;Action;b;Religi... \n \n \n ' where zid = 422", 95, 96, 'ordinal not
in range(128)')
encoding = 'ascii'
end = 96
object = "update zingers set keywords = 'a;Action;b;Religi... \n
\n \n ' where zid = 422"
reason = 'ordinal not in range(128)'
start = 95



the characters I am trying to add are startquote and endquote copied
and pasted from Microsoft Word.



Can anyone help me on this?

Apparently not, since you've already posted this problem on December
18th and got various responses. Did you read
http://effbot.org/pyfaq/how-do-i-escape-sql-values-when-using-the-db-api.htm as Fredrik suggested in the earlier thread?

-Carsten


.



Relevant Pages

  • Re: how to store and still search special characters in Python and MySql
    ... Special characters and punctuation all seem not to be stored and ... Special apostrophes and single quotes from Microsoft Word are causing ... special problem, even though I have ''ed all 's ... 'ascii' codec can't decode byte 0xe2 in position ...
    (comp.lang.python)
  • Re: ASCII convention
    ... I didn't notice any restriction to ASCII in the question, though the question was somewhat obscure and mentioned ASCII at the end. ... Using them just because they "look right" is very unsafe (and I'm not talking about character encoding here). ... encoding without specifying the encoding, ...
    (sci.lang)
  • =?iso-8859-1?q?Re:_About_the_Apparent_Resurrection_of_Thoth_and_Mr_B.C._=83?=
    ... Thoth seems to be best for Mac binaries. ... You are confusing compression with encoding. ... one needs to understand the difference between "binary" and ASCII. ... These are all ASCII encoding formats. ...
    (comp.sys.mac.apps)
  • Re: Padding Bits
    ... hardware platform that uses padding bits. ... etc.), they have committed to using a specific character encoding, ... examples in the book "C Unleashed" in ASCII encoding, ...
    (comp.lang.c)
  • Re: Unicode to ASCII string conversion
    ... files can be ANSI, ASCII, UTF7, UTF8, EBCDIC, UTF16 and many other ... > to string conversion and explicitly no bytearray, ... >> If you need an ASCII file, then use a ASCII encoding. ...
    (microsoft.public.dotnet.languages.vb)