-
Notifications
You must be signed in to change notification settings - Fork 562
Connecting to Netezza
Joe Lee edited this page Apr 2, 2018
·
3 revisions
These unicode connection settings should work with Netezza:
# Python 2.7
cnxn.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
cnxn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
cnxn.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-8')
cnxn.setencoding(str, encoding='utf-8')
cnxn.setencoding(unicode, encoding='utf-8')
# Python 3.x
cnxn.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
cnxn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
cnxn.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-8')
cnxn.setencoding(encoding='utf-8')
If you find that columns names do not decode correctly in Python 3.x, replace
cnxn.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-8')
with
cnxn.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-16le')
Set UnicodeTranslationOption in ~/.odbcinst.ini to utf16:
UnicodeTranslationOption = utf16
and
cnxn.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-16le')