Chapter 4. using hk_classes as a Python module

Table of Contents


You can use hk_classes within Python. You can write your own Python applications using all the elements of hk_classes or interactively explore your data.

Example 4.1. Python module basics

horst@horstnotebook:~> python
Python 2.2.2 (#1, Mar 17 2003, 15:17:58)
[GCC 3.3 20030226 (prerelease) (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from hk_classes import *
>>> dr=hk_drivermanager()
>>> con=dr.new_connection("mysql")
>>> con.set_password("mypassword")
>>> con.connect()
>>> db=con.new_database("exampledb")
>>> mytable=db.new_table("authors")
>>> mytable.enable()


hk_drivermanager handles the database drivers. You need just one object of this type for your whole application.

  • vector<hk_string>* driverlist(void): returns a list of all available database drivers

  • hk_connection* new_connection(const hk_string&drivername): creates a new object of type hk_connection;