I'm using sqlalchemy to connect to a MySQL database and pandas read_sql_query to store the data in a dataframe. Here is my code:
import mysql.connector
import pandas as pd
import pymysql
from sqlalchemy import create_engine
engine = create_engine('mysql+pymysql://' + username + ':' + password + '@' + server + ':' + port + '/' + database)
df = pd.read_sql_query('''
SELECT *
FROM
table
LIMIT 10
''', engine)
One of the columns in the MySQL table that I'm trying to get data from consists utf8 (Persian) characters and when I use the code on my local computer, the result is fine and the utf8 characters can store in the dataframe. But when I'm trying to do the same thing on the remote server with the exact code, the utf8 characters are being replaced with question marks.
How can I get the same results on the server too?
P.S:
- My computer's OS: Ubuntu 18.04
- Server's OS: Ubuntu 16.04