def find_center(id): db = MySQLdb.connect(db="test") cursor = MySQLdb.cursors.Cursor(db) sql = "SELECT X, Y from phot where star_id=%d and mag3 > 1 and err3='NoError' and err4='NoError'" % id cursor.execute(sql) data = result_to_recarray(cursor) res = fmin(f, (800, 600, 150), (data['X'], data['Y'])) return res
def get_data(self, star): #print "DB" keys = [self.x, self.y] keys += [k for k in [self.z, self.s, self.c] if k] db = MySQLdb.connect(db="test") cursor = MySQLdb.cursors.Cursor(db) ss = ", ".join(["%s"]*len(keys)) sql = ("SELECT %s from phot where star_id=%d and mag3 > 1 and err3='NoError' and err4='NoError'" % (ss, star)) sql = sql % tuple(keys) #print sql cursor.execute(sql) data = result_to_recarray(cursor) return data
def get_data(self, star): #print "DB" keys = [self.x, self.y] keys += [k for k in [self.z, self.s, self.c] if k] db = MySQLdb.connect(db="test") cursor = MySQLdb.cursors.Cursor(db) ss = ", ".join(["%s"] * len(keys)) sql = ( "SELECT %s from phot where star_id=%d and mag3 > 1 and err3='NoError' and err4='NoError'" % (ss, star)) sql = sql % tuple(keys) #print sql cursor.execute(sql) data = result_to_recarray(cursor) return data