Unicode issue using flask and mssql guids with FreeTDS
Well, this feels like a hack, but since the only time I'm ever using these guid's is when i'm reading them from the database, I just did:
CAST(REC_GUID_ID as VARCHAR(36)) as REC_GUID_ID
And now they are in a format that everything seems to read just fine.
I have a flask app that recently had to start using mssql generated guid's as primary keys (previously it was just integers). The guid's are latin-1 encoding. Also, I am not using sqlalchemy. Now, when I'm trying to display the queried mssql guid's in a flask jinja2 template, I get the following error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc1 in position 0: ordinal not in range(128).

I've tried:

unsetting the LANG on the linux host
Forcing utf-8 in FreeTDS config (this was already done)
escaping in the jinja template
using python3, no luck
switching from pypyodbc to pyodbc3, but the problem presists

Nothing seems to work. If I import sys and set the decoding to utf-8, the error changes replacing ascii with utf-8, but the jinja template will not render the guid's.
Any thoughts? Thanks for reading. Also to note, my dev environment is on windows 7 and this issue does not crop up there. It's only on the linux server.