hk_database

Represents a particular existing database on the SQL Server. To use it set the name of an existing database with set_name(). To create a new database use hk_connection.create_database().

Inherits from hk_class.

tablelist()

returns a list of all existing tables in this database

querylist()

returns a list of all existing queries in this database

formlist()

returns a list of all existing forms in this database

reportlist()

returns a list of all existing reports in this database

new_table([name[,presentation]])

returns a new table object of type hk_datasource (read and write)

Parameter 'name': the name of the table

Parameter 'presentation': a presentation object (either a form or a report) that administers this table. In most cases you don't have to set this parameter.

new_resultquery([presentation])

returns a new resultquery object of type hk_datasource (readonly)

Parameter 'presentation': a presentation object (either a form or a report) that administers this query. In most cases you don't have to set this parameter.

new_actionquery()

returns a hk_actionquery object. It can execute SQL statements that don't return data and are only successful or not successful (e.g. CREATE TABLE)

load_datasource(name[,query [,presentation]])

a convenience function for new_table and new_resultquery, that loads an existing datasource

delete_table(tablename [,interactive])

deletes a table. Returns True if successful.

Parameter 'tablename': the name of the table

Parameter 'interactive': if set to interactive and the function fails, warning message appears. Possible values

  • hk_class.noninteractive

  • hk_class.interactive

table_exists(tablename)

returns true if the table 'tablename' exists

query_exists(queryname)

returns true if the query 'queryname' exists

new_formvisible()

returns a new form object for the current GUI. If you want to display a new form within the GUI, use this function. If the application is a MDI application, the form will be embedded within the main application window.

new_dialogformvisible()

nearly the same as the above function, but the form will not be embedded in the main application window. Such a form can be used as a dialog in combination with hk_form's show_asdialog() method.

new_reportvisible()

returns a new report object for the current GUI. If you want to display a new report within the GUI, use this function. If the application is a MDI application, the report will be embedded within the main application window.

new_tablevisible()

returns a new table object for the current GUI. If you want to display a new table within the GUI, use this function. If the application is a MDI application, the table will be embedded within the main application window.

new_queryvisible()

returns a new query object for the current GUI. If you want to display a new query within the GUI, use this function. If the application is a MDI application, the query will be embedded within the main application window.

copy_table(fromdatasource,[schema_and_data[,replacetable[,ask]]])

creates a new table and uses an existing datasource as a template

  • fromdatasource the datasource object of type hk_datasource which is used as a template

  • schema_and_data if true the table will be created and the data copied, if false the data will be not copied

  • replacetable see parameter ask for details

  • ask ask=true and replacetable=true => you will be warned before overwriting an old table

    ask=true and replacetable=false => a new name will be asked

    ask=false and replacetable=true => an old table will be overwritten without warning

    ask=false and replacetable=false => copy_table immediately stops and returns false, if a table already exists