Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def top_N_expensive(num_of_highest):
- connection = MySQLdb.connect(host='localhost', user='root', \
- passwd=' ', db='inb104')
- cursor = connection.cursor()
- sql = "SELECT cars_for_sale.make, cars_for_sale.model, +'$'+car_details.price \
- FROM cars_for_sale, car_details WHERE cars_for_sale.CarId = car_details.CarId \
- ORDER BY price DESC,price LIMIT " + str(num_of_highest)
- cursor.execute(sql)
- rows = cursor.fetchall()
- for row in rows:
- print row[0], row[1], row[2]
- cursor.close()
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment