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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -