Before asking this question, I checked other posts for similar ones. The responses provided merely a suppression of the warning, not a remedy.
I have a web application written using Python + Flask that handles asynchronous requests sent with jquery in Unicode format. Content-Type:application/json; charset=UTF-8
Here is an example of the data sent from my web browser to the server. The data may be a combination of Latin and non-Latin characters. I noticed that not Latin characters are codified, but Latin ones are not.
body: "RELATED, RELATED, # RELATED # RELATED RELATED, RELATED. RELATED, REMAINING, RELAX, RELAX, RELAX, RELAX, RELAX, RELAX REMAINING Http://www.allocine.fr/film/fichefilm_gen_cfilm=202971.html "
Here is the definition of my MySqlAlchemy class
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) body = db.Column(db.Unicode(1024))
Now, when I try to send data to the database, I get the following error:
SAWarning: Unicode value obtained by non-unicode bind para m.
param.append (processorskey)
Between me, I use the Flask-Restful component to handle HTTP requests:
class PostListApi(Resource): decorators = [login_required] def post(self): body=request.json['body'] post = Post(body=body) db.session.add(post) db.session.commit()
The question is how to correctly process data on the server side to make sure that non-Unicode characters are not written to the database?