title: Trying to extract values from a PyQt4 QSqlQuery
body: <p>I keep getting an error saying my value is not positioned on a valid record. I've executed my query successfully in MySQL, but I think I'm overlooking something in my code.</p>
  
  <pre><code>query = QtSql.QSqlQuery("select patient_id," +
                          "(SUM(IF(uom_id = 1, value, 0)) / SUM(IF(uom_id = 1, 1, 0))) AS `Average radius`," +
                          "(SUM(IF(uom_id = 2, value, 0)) / SUM(IF(uom_id = 2, 1, 0))) AS `Average Volume`," +
                          "(SUM(IF(uom_id = 3, value, 0)) / SUM(IF(uom_id = 3, 1, 0))) AS `Average SA`" +
                          "from measurements" +
                          "WHERE image_id = " + self.dbImage.id.toString() +
                          "AND status = 'A'" +
                          "GROUP BY patient_id", self.db)
  query.next()
  
  radius_acc = query.value(1).toDouble()
  volume_acc = query.value(2).toDouble()
  SA_acc = query.value(3).toDouble()
  
  print('average of previously accepted measurements includes ' +
        'radius = ' + str(radius_acc) +
        'volume = ' + str(volume_acc) +
        'SA = ' + str(SA_acc))
  </code></pre>
  
  <p>Specifically I want to know if there is something wrong with the way I input the query to QSqlQuery? Or maybe I am trying to use the value(n) method incorrectly?</p>
  
  <p>If neither of those appear to be the case I'll bet I'm using the wrong parameter for self.dbImage.id.toString() in my query, in which case I'll just ask a coworker tomorrow.</p>