Chapter 5. Tips and tricks

5.1. How to display the data


Example 5-1. Show data

   1 horst@horstnotebook:~> python
   2 Python 2.2.2 (#1, Mar 17 2003, 15:17:58)
   3 [GCC 3.3 20030226 (prerelease) (SuSE Linux)] on linux2
   4 Type "help", "copyright", "credits" or "license" for more information.
   5 >>> from hk_classes import *
   6 >>> dr=hk_drivermanager()
   7 >>> con=dr.new_connection("mysql")
   8 >>> con.set_password("secret")
   9 >>> con.connect()
  10 1
  11 >>> db=con.new_database("exampledb")
  12 >>> table=db.new_table("authors")
  13 >>> i=0
  14 >>> table.enable()
  15 SQL : SELECT  *  FROM  `authors`
  16 1
  17 >>> table.goto_first()
  18 1
  19 >>> while i< table.max_rows():
  20     ...    table.show_currentrow()
  21     ...    table.goto_next()
  22     ...    i=i+1
  23 ['1', 'Goethe,Johann Wolfgang', '1749', '1832', 'FALSE']
  24 1
  25 ['2', 'Schiller, Friedrich von', '1759', '1805', 'TRUE']
  26 1
  27 ['3', 'Lessing, Gotthold Ephraim', '1729', '1781', 'TRUE']
  28 1
  29 ['4', 'Kleist', '1400', '0', 'FALSE']