Man page of tw_create_db(3) and tw_erase_db(3)

Index


NAME

tw_create_db, tw_erase_db - create/erase a Textweiser database

SYNOPSIS

 #include <tw.h>

 tw_errno_t tw_create_db(const tw_config_t *cfg);

 tw_errno_t tw_erase_db(const tw_config_t *cfg);

DESCRIPTION

tw_create_db() creates and initializes a new Textweiser database.

tw_erase_db() erases all of Textweiser's data from a Textweiser database.

PARAMETERS

cfg (const tw_config_t *)

Pointer to a Textweiser configuration data structure containing all settings required to connect to the database.

Have a look at CONFIGURATION DATA STRUCTURE below for details.

RETURN VALUE

tw_create_db() and tw_erase_db() return an error indicator (tw_errno_t). A return value of TW_OK indicates success, any other value discriminates the occurred error.

The function tw_strerror(3) can be used to obtain a natural language error message.

CONFIGURATION DATA STRUCTURE

The configuration data structure tw_config_t comprises all settings that may be required to connect to a database. It has to be initialized using the TW_CONFIG_INITIALIZER macro and can be used afterwards. In order to suite the data structure to your needs, assign your configuration settings to the appropriate fields of the data structure:

host (char *)

Hostname of the database server to connect to. (Ignored if the SQLite version of Textweiser is used.)

user (char *)

Username that should be used to log in on the database server. (Ignored if the SQLite version of Textweiser is used.)

passwd (char *)

Password of the user to log in on the database server. (Ignored if the SQLite version of Textweiser is used.)

db_name (char *)

Name of the database that should be used by Textweiser (UTF-8 encoded).

NOTE: If the SQLite version of Textweiser is used, db_name has to be the path to a database file, not necessarily encoded in UTF-8.

port (unsigned int)

Port of the database server to use. (Ignored if the SQLite version of Textweiser is used.)

NOTE: If port is set to 0, Textweiser will assign the default port of the database.

EXAMPLE:

C/C++ #include <tw.h>

 int main(int argc, char **argv)
 {
     tw_config_t cfg = TW_CONFIG_INITIALIZER;

     cfg.db_name = "Example";
     cfg.user    = "Test";

     /* ... */

     return 0;
 }

Besides manual initialization, tw_parse_config(3) may be used to automatically generate a configuration data structure from a configuration file.

SEE ALSO

tw-admin(1)

tw_parse_config(3), tw_strerror(3)

Textweiser User Manual

http://www.lingua-systems.com/text-classifier/textweiser-library/