I am trying to query a MS SQL Server database from a Mac using pandas and pypyodbc. My columns names are returned in Chinese characters. This does not happen when running the code from a Windows-based machine. I tried setting the display encoding properties, but that does not work. It doesn't appear to just be a display issue because I cannot reference the columns such as data['col']
as I get a KeyError: 'col'
import pandas as pd
import pypyodbc
import sys
pd.options.display.encoding = sys.stdout.encoding
connection = pypyodbc.connect('Driver={ODBC Driver 13 for SQL Server};'
'Server=server;'
'Database=database;'
'uid=username;'
'pwd=pw')
data = pd.read_sql("""SELECT * FROM dbo.Table""",con=connection)
print data