[問題] python寫中文到teradata的問題

作者: jeijei (讓我們看雲去)   2018-09-13 00:14:08
大家好
最近要用python3寫資料到teradata
但遇到神奇的事
teradata的VARCHAR欄位
寫入英文與數字沒問題
但寫入中文字就不行了
程式:
connection= pyodbc.connect("driver={Teradata};dbcname=" + host + ";uid=" + user + ";pwd=" + pwd + ";charset=utf8;",
autocommit=True)
connection.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
connection.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
connection.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-8')
connection.setencoding(encoding='utf-8')
cursor= connection.cursor()
cursor.execute("INSERT INTO table(CUSTOMER_ID, HEADQ_BR_CD,
STATUS, OWNER_NAME,
BUSINESS_NAME,ADDRESS,CAPITAL,ORGANIZATION_TYPE,REGISTER_DATE,REGISTER_TYPE,REGISTER_TYPE_NAME)
VALUES('3764H','aa','非營','cc','','','500','','102041','56555','')");
print("ok")
#disconnect
connection.close()
錯誤訊息
作者: TuCH (謬客)   2018-09-13 00:42:00
latin(拉丁) 怎麼會有中文呢...

Links booklink

Contact Us: admin [ a t ] ucptt.com