The knoda scripting tutorial
Prev |  | Next

# Chapter 4. using hk_classes as a Python module

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

       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("mypassword")
       9 >>> con.connect()
      10 1
      11 >>> db=con.new_database("exampledb")
      12 >>> mytable=db.new_table("authors")
      13 >>> mytable.enable()

# 4.1. hk_drivermanager

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;

Prev | Home | Next
Objects of type hk_presentation - forms and reports |  | hk_connection