Python and hebrew encoding/decoding error
Posted
by user340495
on Stack Overflow
See other posts from Stack Overflow
or by user340495
Published on 2010-05-13T16:35:13Z
Indexed on
2010/05/13
16:44 UTC
Read the original article
Hit count: 264
Hey,
I have sqlite database which I would like to insert values in Hebrew to
I am keep getting the following error :
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 0: ordinal
not in range(128)
my code is as following :
runsql(u'INSERT into personal values(%(ID)d,%(name)s)' % {'ID':1,'name':fabricate_hebrew_name()})
def fabricate_hebrew_name():
hebrew_names = [u'????',u'???',u'???',u'???',u'????',u'???',u'????',u'???',u'????',u'?????',u'????',u'???',u'????']
return random.sample(names,1)[0].encode('utf-8')
note: runsql
executing the query on the sqlite database
fabricate_hebrew_name()
should return a string which could be used in my SQL query.
any help is much appreciated.
© Stack Overflow or respective owner