Python and hebrew encoding/decoding error
- by user340495
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.