title: Python import Column Data from MySQL as Array
body: <p>I have this code which retrieves data from a mysql table. I am using Python's MySQLdb module. I want EACH column's data based on the SELECT WHERE condition to be retrieved under an array. For instance, in the code below, I want all the data where location field is 'NY, US' to be retrieved under different arrays - with each array representing different columns values.</p>
  
  <pre><code>import numpy
  import MySQLdb
  
  db = MySQLdb.connect("localhost", "root", "", "test")
  cursor = db.cursor()
  
  sql = "SELECT * FROM usa_new WHERE location = 'NY, US'"
  try:
     cursor.execute(sql)
     results = cursor.fetchall()
     discresults = {}
     for row in results:
  
        id = row[0]
        location = row[1]
        temp_f = row[2]
        pressure_mb = row[3]
        wind_dir = row[4]
        wind_mph = row[5]
        relative_humidity = row[6]
        timestamp = row[7]
  
  except:
     print "Error: unable to fecth data"
  
  db.close()
  </code></pre>
  
  <p>Is there something going wrong?</p>