I'm using pymssql to get some data from the SQL server and store the results in a pandas dataframe. When I try to select a column that contains utf-8 (Farsi) characters, I get this error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xca in position 0: invalid continuation byte
But everything is fine with other columns in the database.
This is my code snippet and I'm running the code with python3.6:
import pymssql
import pandas as pd
conn = pymssql.connect(server, username, password, database)
cursor = conn.cursor(as_dict=True)
cursor.execute("""
SELECT id, title
FROM products
""")
df = pd.DataFrame(columns=['id', 'title'])
for row in cursor:
df = df.append(row, ignore_index=True)
conn.close()