Reputation: 105
I have successfully ran a select statement in mysql as follows:
SELECT * FROM servers ORDER BY FIELD (onlinecheck, 0, NULL, last_reboot) DESC, last_reboot DESC;
How do I run this same statement in Flask_SQLAlchemy?
BIG thanks to those who can assist :)
Upvotes: 1
Views: 142
Reputation: 105
So the best way I found to resolve this is by using a raw query method.
list = db.engine.execute('''SELECT * FROM servers ORDER BY FIELD (onlinecheck, 0, NULL, last_reboot) DESC, last_reboot DESC;''').fetchall()
This resolves the issue. If someone has a better answer I'm all ears.
Upvotes: 1