Sometging wrong with utf-8

86 views
Skip to first unread message

Константин Комков

unread,
Jul 18, 2019, 4:01:30 PM7/18/19
to web2py-users
rows = db(
 
(db.recipes.ID_CUISINE==db.cuisines.id) &
 
(db.recipes.ID_AUTHOR==db.authors.id) &
 
(db.recipes.ID_CATEGORY==db.categories.id)
 
).select(db.cuisines.NAME,db.authors.NAME,db.categories.NAME,db.recipes.ALL)

Ticket ID

127.0.0.1.2019-07-18.22-56-57.1cf3eb52-85aa-418d-b7f9-51ac287014a9

<class 'UnicodeDecodeError'> 'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte

Версия

web2py™Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
PythonPython 3.7.3: C:\Program Files (x86)\Python37-32\python.exe (prefix: C:\Program Files (x86)\Python37-32)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
Traceback (most recent call last):
File "D:\Загрузки\web2py_src\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "D:\Загрузки\web2py_src\web2py\applications\Recipes\controllers/default.py", line 89, in <module>
File "D:\Загрузки\web2py_src\web2py\gluon\globals.py", line 421, in <lambda>
self._caller = lambda f: f()
File "D:\Загрузки\web2py_src\web2py\applications\Recipes\controllers/default.py", line 19, in index
).select(db.cuisines.NAME,db.authors.NAME,db.categories.NAME,db.recipes.ALL)
File "D:\Загрузки\web2py_src\web2py\gluon\packages\dal\pydal\objects.py", line 2395, in select
return adapter.select(self.query, fields, attributes)
File "D:\Загрузки\web2py_src\web2py\gluon\packages\dal\pydal\adapters\base.py", line 763, in select
return self._select_aux(sql, fields, attributes, colnames)
File "D:\Загрузки\web2py_src\web2py\gluon\packages\dal\pydal\adapters\base.py", line 719, in _select_aux
rows = self._select_aux_execute(sql)
File "D:\Загрузки\web2py_src\web2py\gluon\packages\dal\pydal\adapters\base.py", line 714, in _select_aux_execute
return self.cursor.fetchall()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py", line 3730, in fetchall
return [row for row in self]
File "C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py", line 3730, in <listcomp>
return [row for row in self]
File "C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py", line 3488, in next
row = self.fetchone()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py", line 3690, in fetchone
return self._ps._fetchone()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py", line 3359, in _fetchone
return self.__xsqlda2tuple(self._out_sqlda)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py", line 2677, in __xsqlda2tuple
value = b2u(value, self.__python_charset)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py", line 479, in b2u
return st.decode(charset)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte

Error snapshot help

UnicodeDecodeError('utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte)

inspect attributes

Frames

Константин Комков

unread,
Jul 19, 2019, 1:01:26 PM7/19/19
to web2py-users
rows = db(
        (db.recipes.ID_CUISINE==db.cuisines.id)
    ).select(db.recipes.ALL)
db._lastsql >>>
('SELECT recipes.ID_CUISINE, recipes.DESCRIPTION, recipes.ID_AUTHOR, recipes.ID_CATEGORY, recipes.EXPIRATION_DATE, recipes.IMAGE FROM recipes, cuisines WHERE (recipes.ID_CUISINE = cuisines.id);', 0.04505515098571777)
rows = db(
       
(db.recipes.ID_CUISINE==db.cuisines.id)
   
).select(db.recipes.ALL,db.cuisines.NAME)
db._lastsql >>> Error: 'utf-8' codec can't decode byte 0xf0
rows = db(db.recipes).select(join=db.cuisines.on(db.recipes.ID_CUISINE == db.cuisines.id))
db._lastsql >>> Error: 'utf-8' codec can't decode byte 0xf0
my tables:
db.define_table(
   
'recipes',
   
Field('ID_CUISINE','integer'),
   
Field('DESCRIPTION'),
   
Field('ID_AUTHOR','integer'),
   
Field('ID_CATEGORY','integer'),
   
Field('EXPIRATION_DATE'),
   
Field('IMAGE'),
    primarykey
=['ID_CUISINE','ID_AUTHOR','ID_CATEGORY'],
    migrate
=False
)

db
.define_table(
   
'cuisines',
   
Field('NAME','string'),
    migrate
=False
)

Константин Комков

unread,
Jul 19, 2019, 1:28:31 PM7/19/19
to web2py-users
That error was created becouse in 'cuisines' table field NAME have charset 'NONE' and collate 'NONE'. 
Reply all
Reply to author
Forward
0 new messages