I do a small project on a flask. At first I did it on a Windows 10 computer in pycharm - everything works fine, then it's time to roll it out to the server - nothing works and gives these errors when trying to perform some actions:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range (128)
As far as I was able to understand, similar errors occur when processing data sent from forms and when attempting to write to the database (on sqlite3). But it is not exactly. All files seem to be in UTF-8, I don’t even know which way to dig and what to do.
The error occurs in many places, but here is one example:
project_queries = str(project_queries) + str(q.query_text) + '\n' This is a line from the function:
def get_project_by_id(id): session = Session(bind=engine) project_data = session.query(Project).filter(Project.id == id).first() project_queries_in_list = session.query(Phrase).filter(Phrase.project == id, Phrase.enable == True).all() project_queries = '' for q in project_queries_in_list: project_queries = str(project_queries) + str(q.query_text) + '\n' project_info = {'id': project_data.id, 'name': project_data.name, 'domain': project_data.domain, 'queries': project_queries} session.close() return project_info