database select from set encoding

57 views
Skip to first unread message

Yebach

unread,
Dec 29, 2014, 8:53:37 AM12/29/14
to web...@googlegroups.com
hello

I have a postgres dabatabase with utf8 encoding 

after executing 
workersDb = db(db.worker.w_organisation == org).select(db.worker.id, db.worker.w_nick_name).as_list()

I get a list of dict where my strings are endoed as 

'Moj\xc4\x8dca'

where it should write Mojčca

How do i set the encoding?

Thank you


Marco Mansilla

unread,
Dec 29, 2014, 11:20:09 AM12/29/14
to web...@googlegroups.com
El Mon, 29 Dec 2014 05:53:37 -0800 (PST)
Yebach <vid....@gmail.com> escribió:
right at the end of the section

http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Connection-strings--the-uri-parameter-

Marco.

Vid Ogris

unread,
Dec 30, 2014, 2:41:56 AM12/30/14
to web...@googlegroups.com
Hello

Setting db_codec changes nothing


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/uUf6xZaUY_Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lep pozdrav 

Vid Ogris


Niphlod

unread,
Dec 30, 2014, 9:32:16 AM12/30/14
to web...@googlegroups.com
let's tackle the problem from another side: if you avoid using DAL and resort to "pure" psycopg2, does it work ? If yes, can you post the code ? From there we can compare what DAL does and pinpoint the root cause accordingly.

Michele Comitini

unread,
Dec 30, 2014, 1:37:35 PM12/30/14
to web...@googlegroups.com
the string is a utf-8 encoded string not unicode object

>>> print 'Moj\xc4\x8dca'.decode('utf-8')
Mojčca



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 web2py+un...@googlegroups.com.

Vid Ogris

unread,
Jan 2, 2015, 10:03:41 AM1/2/15
to web...@googlegroups.com
decode('utf-8') crashes my view. and I can't find the error

Paolo Valleri

unread,
Jan 2, 2015, 12:18:43 PM1/2/15
to web...@googlegroups.com
Postgres adapter sets client_adapter to UTF8 https://github.com/web2py/pydal/blob/master/pydal/adapters/postgres.py#L147
Do you have the same problem without the as_dict?
If you have direct (command line) access to the db, post the content of the field.

Paolo
Reply all
Reply to author
Forward
0 new messages