<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >hk_connection</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="The knoda scripting tutorial" HREF="index.html"><LINK REL="UP" TITLE="using hk_classes as a Python module" HREF="chapter4.html"><LINK REL="PREVIOUS" TITLE="using hk_classes as a Python module" HREF="chapter4.html"><LINK REL="NEXT" TITLE="hk_database" HREF="hk_database.html"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="stylesheet" HREF="common/kde-common.css" TYPE="text/css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META HTTP-EQUIV="Content-Language" CONTENT="en"><LINK REL="stylesheet" HREF="common/kde-localised.css" TYPE="text/css" TITLE="KDE-English"><LINK REL="stylesheet" HREF="common/kde-default.css" TYPE="text/css" TITLE="KDE-Default"></HEAD ><BODY CLASS="SECTION" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#AA0000" VLINK="#AA0055" ALINK="#AA0000" STYLE="font-family: sans-serif;" ><DIV CLASS="logoheader" ><A HREF="http://www.kde.org/" ></A ></DIV ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The knoda scripting tutorial</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="chapter4.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 4. using hk_classes as a Python module</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="hk_database.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECTION" ><H1 CLASS="SECTION" ><A NAME="HK_CONNECTION" ></A >4.2. hk_connection</H1 ><P > hk_connection connects to the SQL Server. The most important functions are set_host(), set_user(), set_password() and connect(). <A NAME="AEN367" ></A ><BLOCKQUOTE CLASS="BLOCKQUOTE" ><UL ><LI STYLE="list-style-type: disc" ><P >void set_host(const hk_string& ): sets the host name or host IP number</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_string host(void)</P ></LI ><LI STYLE="list-style-type: disc" ><P >void set_user(const hk_string& ): sets the user name used on the host</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_string user(void)</P ></LI ><LI STYLE="list-style-type: disc" ><P >void set_password(const hk_string& p): sets the password for the user</P ></LI ><LI STYLE="list-style-type: disc" ><P >void set_tcp_port(unsigned int t): sets the TCP port</P ></LI ><LI STYLE="list-style-type: disc" ><P >unsigned int tcp_port(void);</P ></LI ><LI STYLE="list-style-type: disc" ><P >virtual unsigned int default_tcp_port(void) const: returns the default TCP port for this database server</P ></LI ><LI STYLE="list-style-type: disc" ><P >bool connect(enum_interaction c=interactive): connects to the server using the user, host and TCP data</P ></LI ><LI STYLE="list-style-type: disc" ><P >bool disconnect(void): disconnects from the server</P ></LI ><LI STYLE="list-style-type: disc" ><P >bool is_connected(void): returns true if this connection is connected to the server</P ></LI ><LI STYLE="list-style-type: disc" ><P >vector<hk_string>* dblist(void): returns a list of all existing databases in this connection</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_database* new_database(const hk_string& name=""): creates a new hk_database object</P ></LI ><LI STYLE="list-style-type: disc" ><P >bool create_database(const hk_string& dbase): creates a new database if the server supports this</P ></LI ><LI STYLE="list-style-type: disc" ><P >bool delete_database(const hk_string& dbase): deletes an exisiting database</P ></LI ><LI STYLE="list-style-type: disc" ><P >bool database_exists(const hk_string& databasename):returns true if the database "databasename" exists</P ></LI ></UL ></BLOCKQUOTE > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="chapter4.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="hk_database.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >using hk_classes as a Python module</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="chapter4.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >hk_database</TD ></TR ></TABLE ></DIV ></BODY ></HTML >