我想從python 2.6中獲取SQL Server 2008中的字段。這是我的freetds的.conf文件:在freetds中使用pymssql時的UnicodeDecodeError
[ARGSERVER03]
host = 192.168.1.3
port = 1433
tds version = 7.0
這裏是代碼:
conn = pymssql.connect(host='192.168.1.3', user='****', password='****', database='TrafficMonitor', as_dict=True, charset='UTF-8')
i = 0
cur.execute('SELECT * FROM dbo.tblTrafficCounterData')
while i < 10:
car = cur.fetchone_asdict()
if car is None:
break
c = car['Class']
print c
i = i + 1
但它給:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd3 in position 0: invalid continuation byte
Unicode的領域是波斯語。該追溯是線car = cur.fetchone_asdict()
[編輯]
我已經從SQL Server Management Studio數據庫性能檢查數據庫歸類,它是:
Arabic_CI_AS
但是,當我使用在它給出的字符集:
LookupError: unknown encoding: Arabic_CI_AS
這個錯誤似乎是非常類似:HTTP:/ /stackoverflow.com/questions/9090915/how-to-read-large-file-with-unicode-in-python-3 – 2012-04-04 12:45:02