7.4. SQL and Database Infrastructure

7.4.1. dbi_conn_connect

int dbi_conn_connect(dbi_conn Conn);

Connects to the database using the options (host, username, password, port, (etc.) set with dbi_conn_set_option and related functions. See the documentation for each specific database driver for the options it recognizes and requires.

Arguments

Conn: The target connection.

Returns

0 (zero) on success, less than zero on failure. In the latter case, the error number may be DBI_ERROR_NOMEM, DBI_ERROR_NOCONN, or one of the driver-specific values.

7.4.2. dbi_conn_get_db_list

dbi_result dbi_conn_get_db_list(dbi_conn Conn, const char *pattern);

Queries the list of available databases on the server.

Arguments

Conn: The target connection.

pattern: A string pattern (SQL regular expression) that each name must match, or NULL to show all available databases.

Returns

A query result object, which will contain database names in the first field (for use with the by-index field functions). In case of an error, the function returns NULL and sets the error number to a database engine-specific nonzero value.

7.4.3. dbi_conn_get_table_list

dbi_result dbi_conn_get_table_list(dbi_conn Conn, const char *db, const char *pattern);

Queries the list of available tables in a particular database.

Arguments

Conn: The target connection.

db: The target database name.

pattern: A string pattern (SQL regular expression) that each name must match, or NULL to show all available tables.

Returns

A query result object, which will contain table names in the first field (for use with the by-index field functions). In case of an error, the function returns NULL and sets the error number to a database engine-specific nonzero value.

7.4.4. dbi_conn_select_db

int dbi_conn_select_db(dbi_conn Conn, const char *db);

Switches to a different database on the server.

Arguments

Conn: The target connection.

db: The target database name.

Returns

-1 on failure, zero on success. In case of an error, the error number may be DBI_ERROR_UNSUPPORTED or a database engine-specific nonzero value.