NaviServer - programmable web server


[ Main Table Of Contents | Table Of Contents | Keyword Index ]

nsdbi(3) 4.99.3 nsdbi "NaviServer Database Interface"

Name

nsdbi - Register a database driver implementation

Table Of Contents

Synopsis

Description

The following routines are available for database-specific driver modules.

FUNCTIONS

Dbi_RegisterDriver(CONST char *server, CONST char *module, CONST char *driver, CONST char *database, CONST Dbi_DriverProc *procs, ClientData configData)

Register a set of Dbi_DriverProc callbacks to provide access to a new type of database. Call this from your module's Ns_ModuleInit() routine.

ARGUMENTS

char *server (in)

The name of a virtual server.

char *module (in)

The name of the module instance.

char *driver (in)

The name this driver is known by.

char *database (in)

The name of the database this driver connects to. e.g. "sqlite".

Dbi_DriverProc *procs (in)

The structure used to pass callbacks during driver registration.

EXAMPLES

Log the number of connections handled by a single TCP socket:

#include "nsdbidrv.h"
NS_EXPORT int Ns_ModuleVersion = 1;
static Dbi_DriverProc procs = {
    {Dbi_OpenProcId,         Open},
    {Dbi_CloseProcId,        Close},
    {Dbi_ConnectedProcId,    Connected},
    {Dbi_BindVarProcId,      Bind},
    {Dbi_PrepareProcId,      Prepare},
    {Dbi_PrepareCloseProcId, PrepareClose},
    {Dbi_ExecProcId,         Exec},
    {Dbi_NextRowProcId,      NextRow},
    {Dbi_ColumnLengthProcId, ColumnLength},
    {Dbi_ColumnValueProcId,  ColumnValue},
    {Dbi_ColumnNameProcId,   ColumnName},
    {Dbi_TransactionProcId,  Transaction},
    {Dbi_FlushProcId,        Flush},
    {Dbi_ResetProcId,        Reset},
    {0, NULL}
};
int
Ns_ModuleInit(CONST char *server, CONST char *module)
{
    static CONST char *drivername = "dbdriver";
    static CONST char *database   = "db";
    return Dbi_RegisterDriver(server, module,
                              drvername, database,
                              procs, NULL);
}
static int
Open(ClientData configData, Dbi_Handle *handle)
{
    ...
}
...

See Also

Dbi_GetHandle, Dbi_SetException, Dbi_TclGetHandle, nsdbi

Keywords

NaviServer, database, driver, query, sql