Would like to just display 3 rows from mySQL result in python -
so right have query returns 20 rows. need these later
cur.execute(query) rows in cur.fetchall(): print(rows) cur.close() conn.close()
how write loop write row in range 1-3?
use slice notation first 3 items rows. http://www.pythoncentral.io/how-to-slice-listsarrays-and-tuples-in-python/
for row in cur.fetchall()[:3]: print row
Comments
Post a Comment