I have a little app which takes users coordinates from client and searches for a nearest location in my mySQL database. I need to grab the results from my database and save them to a file or assign these results to a variable. What do I need to add to a code below to achieve it?
import mysql.connector
mycursor = mydb.cursor()
mycursor.execute("SELECT dbx, dby, SQRT(
POW(69.1 * (dbx - userx), 2) +
POW(69.1 * (usery - dby) * COS(latitude / 57.3), 2)) AS distance
FROM TableName HAVING distance < 125 ORDER BY distance;")
mydb.commit()
dbx and dby are longitude and latitude parameters from the points which are stored in database
userx and usery are longitude and latitude parameters taken from the client-side.
SELECT .. INTO OUTFILE.