#!/usr/bin/python # Python MySql tester # RJM Programming # October, 2017 # Thanks to https://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python import MySQLdb db = MySQLdb.connect(host="localhost", # your host, usually localhost user="root", # your username passwd="root", unix_socket="/Applications/MAMP/tmp/mysql/mysql.sock", db="testdb") # name of the data base # you must create a Cursor object. It will let # you execute all the queries you need cur = db.cursor() # Use all the SQL you like cur.execute("SELECT * FROM CIRCLE,POINT where originid=pointid") # print some cells of all the rows print "radius", "x ", "y" for row in cur.fetchall(): print row[2], row[4], row[5] db.close()