Reputation: 1242
My question: Why can't I retrieve non-ascii chars from sqlalchemy db into python?
In more detail: I have an entry with non-ascii char in my sqlalchemy db (Umlaut for example). When I try to retrieve this entry by using:
q=self.session.query(Table_Name).filter(Table_Name.id=='some id')
q.all()
I receive the following error:
UnicodeEncodeError: 'ascii' codec can't encode characters in position
I solved it by decoding the entries into UTF-8 before inserting the entry to the DB.
Yet I wondered - why does this error appeared? Is there an option to fetch entries already encoded as unicode for example instead of bytechar\ascii into python?
Upvotes: 3
Views: 1120