python - UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 105: invalid continuation byte -




my code pretty following :

import sqlitefts fts  connection = apsw.connection('texts.db', flags=apsw.sqlite_open_readwrite) c = connection.cursor() def do_search(query):     c.execute('select title, book, author, link, snippet(text_idx) text_idx  text_idx match 'possumus';') #in case query='possumus'     c.fetchall() --display results on html-- 

the query works if search more single word. when single word searches throws me decoding error.

query doesn't work similar following:

single word searches -

select title, book, author, link, snippet(text_idx)  text_idx   text_idx match 'possumus';  

and or searches like

select title, book, author, link, snippet(text_idx)  text_idx   text_idx match 'quam or galliae'; 

the stack trace is:

traceback (most recent call last):   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1997, in __call__     return self.wsgi_app(environ, start_response)   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1985, in wsgi_app     response = self.handle_exception(e)   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1540, in handle_exception     reraise(exc_type, exc_value, tb)   file "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise     raise value   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1982, in wsgi_app     response = self.full_dispatch_request()   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1614, in full_dispatch_request     rv = self.handle_user_exception(e)   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1517, in handle_user_exception     reraise(exc_type, exc_value, tb)   file "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise     raise value   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1612, in full_dispatch_request     rv = self.dispatch_request()   file "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1598, in dispatch_request     return self.view_functions[rule.endpoint](**req.view_args)   file "/home/ramcharran/phyllo/search/app.py", line 123, in search     r = do_search(query)   file "/home/ramcharran/phyllo/search/app.py", line 90, in do_search     r1 = c.fetchall() unicodedecodeerror: 'utf-8' codec can't decode byte 0xe2 in position 105: invalid continuation byte 

the query works fine if not use snippet() function in query.

i think problem due coding. may tehere special characters in text_idx column try put:

# coding: latin1 

at beginning of file. must replace latin1 encoding fits case. hope i've helped.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -