1.sqlalchemy query data, sort according to the data in the field (Chinese) to Pinyin (ascending order)
2. It is known that there are func.convert and sql.func.CONVERT methods in sqlalchemy, and the import method is
from sqlalchemy import func
from sqlalchemy import sql
here"s how I implement it
self.db.query(Table).order_by(
sql.func.CONVERT(sql.literal_column("VARCHAR(8)"),
Table.department_name, sql.literal_column("8"))).all()
result hint:
ProgrammingError: (_ mysql_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 "VARCHAR (8), Table.department_name, 8)
I don"t know how to implement it.