I'm creating a method which takes a name as an argument and returns a row from Sqlite3 database. When trying to use non-diacritic characters, it works.
But if I try to pass a string which contains diacritic characters, it raises:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)
When I try to print the same name to the console, it works.
# -*- coding: utf-8 -*-
import sqlite3
conn = sqlite3.connect('data.db')
cur = conn.cursor()
def get_subject_by_name(name): # TODO: APROXIMATE SEARCH
result = cur.execute("""SELECT nazov,ICO,pravna_forma,sidlo,predmet_cinnosti,den_zapisu,url_orsr FROM companies WHERE nazov LIKE ?""",('{}%'.format(name),)).fetchall()
print result
get_subject_by_name(u"systém")
do you know where the problem could be?
Aucun commentaire:
Enregistrer un commentaire