I'm using the SQLAlchemy ORM to construct the MySQL queries in my application, and am perfectly able to add basic filters to the query, like so:
query = meta.Session.query(User).filter(User.user_id==1)
Which gives me something basically equivalent to this:
SELECT * FROM users WHERE user_id = 1
My question is how I would integrate some basic MySQL math functions into my query. So, say for instance I wanted to get users near a certain latitude and longitude. So I need to generate this SQL ($mylatitude and $mylongitude are the static latitude and longitude I'm comparing against):
SELECT * FROM users
WHERE SQRT(POW(69.1 * (latitude - $mylatitude),2) + POW(53.0 * (longitude - $mylongitude),2)) < 5
Is there a way I can incorporate these functions into a query using the SQLAlchemy ORM?