Guest User

Untitled

a guest
May 21st, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. def top_N_expensive(num_of_highest):
  2. connection = MySQLdb.connect(host='localhost', user='root', \
  3. passwd=' ', db='inb104')
  4. cursor = connection.cursor()
  5. sql = "SELECT cars_for_sale.make, cars_for_sale.model, +'$'+car_details.price \
  6. FROM cars_for_sale, car_details WHERE cars_for_sale.CarId = car_details.CarId \
  7. ORDER BY price DESC,price LIMIT " + str(num_of_highest)
  8. cursor.execute(sql)
  9.  
  10. rows = cursor.fetchall()
  11. for row in rows:
  12. print row[0], row[1], row[2]
  13.  
  14. cursor.close()
  15. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment