Make sure that your source file is encoded as UTF-8. The following code works for me:
# -*- coding: utf-8 -*-
import pyodbc
connStr = (
r'Driver={SQL Server};' +
r'Server=127.0.0.1,52865;' +
r'Database=myDb;' +
r'Trusted_Connection=Yes;'
)
db = pyodbc.connect(connStr)
sql = "SELECT word FROM vocabulary WHERE ID=1"
cursor1 = db.execute(sql)
while 1:
row = cursor1.fetchone()
if not row:
break
print row.word
cursor1.close()
db.close()
Note the coding hint in the first line. The result that appears in the Python shell (IDLE) is
你好