我想从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