大家好
最近要用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()
錯誤訊息