469,917 Members | 1,968 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Special Characters (Unicode, Ascii) in Python and MySQL

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?

bests,

-rsr-

Jan 2 '07 #1
1 2830
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-esc...the-db-api.htm as Fredrik suggested in the earlier thread?

-Carsten
Jan 2 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Tetsuo | last post: by
11 posts views Thread by Marian Aldenhvel | last post: by
20 posts views Thread by SMG | last post: by
19 posts views Thread by many_years_after | last post: by
2 posts views Thread by joakim.hove | last post: by
3 posts views Thread by sophie_newbie | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.