Error 1064 on python flask when executing a select request

时间:2019-03-19 14:45:56

标签: python mysql python-3.x flask flask-sqlalchemy

I facing an error on Debian. I have a mysql request in my flask app. The same request work locally (but locally my machine run on Windows).

I guess the problem come from mysql_secure_installation but i'm not sure.

This is my request :

consommation = db.session.query(ConsommationHT.Date_conso, label('jour', func.sum(ConsommationHT.Conso_Tranche_Jour)), label('pointe', func.sum(ConsommationHT.Conso_Tranche_Pointe)), label('nuit', func.sum(ConsommationHT.Conso_Tranche_Nuit))).filter(ConsommationHT.Compteur==current_user.Compteur).group_by(asc(sa.func.year(ConsommationHT.Date_conso)), asc(sa.func.month(ConsommationHT.Date_conso))).all()

And this the error i get

mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC, month(conso_ht.`Date_conso`) ASC' at line 3")

How can i solve it ?

0 个答案:

没有答案