Найти - Пользователи
Полная версия: SQLite + python sqllite3
Начало » Базы данных » SQLite + python sqllite3
1
yuriyb
Hello ,

я в не силен v python
вот етот скрипт хорошо работает с прилагаемым

http://www.aot.ru/download/Morphology.zip

db cache
но вот при попытке сгенериривать новый cache
т е при вызове

morph = Morphology.Morphology('morph','morphs.mrd')

выдает кучу ошибок


<class ‘sqlite3.ProgrammingError’>: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
args = ('You must not use 8-bit bytestrings unless you us… just switch your application to Unicode strings.',)
message = ‘You must not use 8-bit bytestrings unless you us… just switch your application to Unicode strings.’


я полагаю что проблема в более новой версии

может кто подсказать как можно исправить ?





<class ‘sqlite3.ProgrammingError’> Python 2.6.4: D:\Python26\python.exe
Thu Dec 10 15:30:24 2009

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
D:\xampp\htdocs\AOT\test5.py in ()
14
15
16 morph = Morphology.Morphology('morph','morphs.mrd')
17 print “Content-type: text/html;charset=utf-8\n\n”
18
morph undefined, Morphology = <module ‘Morphology’ from ‘D:\xampp\htdocs\AOT\Morphology.py’>, Morphology.Morphology = <class Morphology.Morphology at 0x00C1C5A0>
D:\xampp\htdocs\AOT\Morphology.py in __init__(self=<Morphology.Morphology instance at 0x00C15940>, db='morph', lexicon='morphs.mrd')
52
53 if load:
54 self.load(lexicon)
55
56 def close(self):
self = <Morphology.Morphology instance at 0x00C15940>, self.load = <bound method Morphology.load of <Morphology.Morphology instance at 0x00C15940>>, lexicon = ‘morphs.mrd’
D:\xampp\htdocs\AOT\Morphology.py in load(self=<Morphology.Morphology instance at 0x00C15940>, file='morphs.mrd')
93 return False
94
95 print self.load_lemmas(handle), ‘lemmas loaded’
96
97 handle.close()
self = <Morphology.Morphology instance at 0x00C15940>, self.load_lemmas = <bound method Morphology.load_lemmas of <Morphology.Morphology instance at 0x00C15940>>, handle = <open file ‘morphs.mrd’, mode ‘r’ at 0x00AA3D90>
D:\xampp\htdocs\AOT\Morphology.py in load_lemmas(self=<Morphology.Morphology instance at 0x00C15940>, handle=<open file ‘morphs.mrd’, mode ‘r’ at 0x00AA3D90>)
146
147 record = reg_split.split(line)
148 self.db.execute('insert into lemmas values(?, ?)', (record.lower() + ‘%’, int(record)))
149
150 self.db.execute('create index lemmas_base on lemmas(base)')
self = <Morphology.Morphology instance at 0x00C15940>, self.db = <sqlite3.Cursor object at 0x00C1C5C0>, self.db.execute = <built-in method execute of sqlite3.Cursor object at 0x00C1C5C0>, record = , ].lower undefined, builtin int = <type ‘int’>

<class ‘sqlite3.ProgrammingError’>: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
args = ('You must not use 8-bit bytestrings unless you us… just switch your application to Unicode strings.',)
message = ‘You must not use 8-bit bytestrings unless you us… just switch your application to Unicode strings.’
yuriyb
PITAJUS perekodiroat v utf-8

u = unicode(record.lower())

vidaet

<type ‘exceptions.UnicodeDecodeError’>: ‘ascii’ codec can't decode byte 0xc7 in position 4: ordinal not in range(128)
yuriyb
script viletaet kogda

print record # aper&#231;u

# aper&#231;u

kak s etim borotisja ?
regall
Поищите по форуму с ключевым словом “кодировка”, уверен найдете решение.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB