UnicodeError: ASCII decoding error: ordinal not in range(128)
Gerhard Haering
gerhard at bigfoot.de
Fri Jul 19 23:46:30 EDT 2002
* eugene kim <eugene1977 at hotmail.com> [2002-07-19 22:44 -0500]:
> thank you for helping me..
> i'm sure that i encoded all strings to unicode
> (title,url)
> but it still gives me error..
> =)
What about self.firsttime? As your code looks like:
> cursor.execute("insert into history (col1, col1, col3) values (%s, %s, %s)",
> (self.url, self.title, self.firsttime))
what about a
print map(type, (self.url, self.title, self.firsttime))
to test if you're really not using any Unicode strings there? :-)
> this is so cool.. what module do i need to use? pypgsql?
Of course I'd be all for pyPgSQL :) But in this particular case, all other
PostgreSQL modules work exactly the same.
> yet another question, how do i check which module i have in my current
> system?
There's no good answer, as there is no databas of installed Python packages
(yet). You can try to import and look if you get an ImportError:
from pyPgSQL import PgSQL # pyPgSQL
import psycopg # psycopg
import pgdb # PyGreSQL
to look which PostgreSQL modules you have installed.
> (one more irrelevant question: is this also possible in java?)
Java has Unicode strings only. And there's also a JDBC driver for PostgreSQL,
which at some point will encode the Unicode strings to a bytestring for you.
I'm not sure I understand your question, though.
Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list
mailing list