Looks like the issue is: str(query)
The query is a unicode object by default, and á can't be converted to a 
string, since it's outside the ascii character set.

Try this instead:
print u"DEBUG: query = " + query



On Tuesday, 30 May 2017 11:07:30 UTC+1, Karoly Kantor wrote:
>
> Please help:
>
> I have this:
>
>             print "DEBUG: query = " + str(query)
>             result = mydb(query).select(*column_names)
>             print db._lastsql
>
> This will print this into the log:
>
> DEBUG: query = ((((record.application = 3) AND (record.entity = 24)) AND 
> (record.is_deleted = 'F')) AND ((record.is_deleted = 'F') AND 
> (record.string_1 = 'Puskás Ferenc')))
>
> Please observe the accented 'a' character: "á". Also, mydb equals to db in 
> this case. 
>
> This will raise this error (from the GAE logs):
>
> print db._lastsql File 
> "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/request_environment.py",
>  
> line 92, in write self._request.errors.write(data) File 
> "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/logservice/logservice.py",
>  
> line 286, in write for line in cStringIO.StringIO(lines): 
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in 
> position 212: ordinal not in range(128)
>
> However:
>
> 1. If I comment out the print db._lastsql part, my app suddenly works as 
> expected,
>
> 2. Except, querying on "Puskas Ferenc" and "Puskás Ferenc" both retrieves 
> the same item from the table (which has an "á").
>
> Maybe, can someone give me a hint on what's going on here?
>
> My server connection collation is set to utf8mb4_unicode_ci and the table 
> collation to utf8_general_ci (this was all default in Google Cloud SQL, I 
> have not changed them)
>
> Thank you! 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to