Last Updated: February 25, 2016
·
1.991K
· butenas_com

PostgreSql, flask and Unicode problem solution

If you are having problems with PostgreSql, unicode and Flask framework and seeing something like this:

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

Try this:

import psycopg2
import psycopg2.extensions
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)